Opened 7 years ago
Closed 7 years ago
#17561 closed enhancement (fixed)
Speed up vectors
Reported by:  jdemeyer  Owned by:  

Priority:  minor  Milestone:  sage6.5 
Component:  performance  Keywords:  
Cc:  Merged in:  
Authors:  Jeroen Demeyer  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  106f5d4 (Commits, GitHub, GitLab)  Commit:  106f5d41398794b13a6a683236cf219d49602312 
Dependencies:  Stopgaps: 
Description (last modified by )
We should declare the types _entries
in free_module_element.pxd
. This leads to a significant speedup in the sparse case, and a minor speedup in the dense case:
Before:
sage: v = vector(RR, range(10000)); timeit('v._add_(v)', repeat=10, number=1000) 1000 loops, best of 10: 1.85 ms per loop sage: v = vector(RR, range(10000), sparse=True); timeit('v._add_(v)', repeat=10, number=1000) 1000 loops, best of 10: 3.49 ms per loop
After:
sage: v = vector(RR, range(10000)); timeit('v._add_(v)', repeat=10, number=1000) 1000 loops, best of 10: 1.82 ms per loop sage: v = vector(RR, range(10000), sparse=True); timeit('v._add_(v)', repeat=10, number=1000) 1000 loops, best of 10: 2.85 ms per loop
Change History (15)
comment:1 Changed 7 years ago by
 Description modified (diff)
comment:2 Changed 7 years ago by
 Description modified (diff)
 Summary changed from Declare types in free_module_element to Speed up vectors
comment:3 Changed 7 years ago by
 Branch set to u/jdemeyer/ticket/17561
 Created changed from 12/29/14 08:17:20 to 12/29/14 08:17:20
 Modified changed from 12/29/14 09:57:46 to 12/29/14 09:57:46
comment:4 Changed 7 years ago by
 Commit set to 1233d6d27e83a6f359d9e2e1121c7cbbd06803a0
comment:5 Changed 7 years ago by
 Status changed from new to needs_review
comment:6 Changed 7 years ago by
 Status changed from needs_review to needs_work
comment:7 Changed 7 years ago by
 Description modified (diff)
comment:8 Changed 7 years ago by
 Commit changed from 1233d6d27e83a6f359d9e2e1121c7cbbd06803a0 to df0fb69e1aa9ab205e35b98ad6d97d0c67b889af
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
df0fb69  Declare types of _entries

comment:9 Changed 7 years ago by
 Status changed from needs_work to needs_review
comment:10 followup: ↓ 11 Changed 7 years ago by
Is there a reason why you do
if type(entries) is not dict:
instead of
if isinstance(entries, dict):
?
comment:11 in reply to: ↑ 10 Changed 7 years ago by
 Status changed from needs_review to needs_work
Replying to tscrim:
Is there a reason why you do
if type(entries) is not dict:instead of
if isinstance(entries, dict):?
Yes, I need to assign it _entries
which is declared as dict
. So the type really has to be dict
, not some derived type.
But we should support derived types, which is not currently the case.
comment:12 Changed 7 years ago by
 Commit changed from df0fb69e1aa9ab205e35b98ad6d97d0c67b889af to 106f5d41398794b13a6a683236cf219d49602312
Branch pushed to git repo; I updated commit sha1. New commits:
106f5d4  Minor improvements in FreeModuleElement_generic_sparse.__init__

comment:13 Changed 7 years ago by
 Status changed from needs_work to needs_review
comment:14 Changed 7 years ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
I see. I was thinking too much like in Java or pointers in C++. LGTM.
comment:15 Changed 7 years ago by
 Branch changed from u/jdemeyer/ticket/17561 to 106f5d41398794b13a6a683236cf219d49602312
 Resolution set to fixed
 Status changed from positive_review to closed
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
Speed up vectors