Mike Hansen wrote:
> On 10/3/07, David Joyner <[EMAIL PROTECTED]> wrote:
>> On 10/3/07, Jason Grout <[EMAIL PROTECTED]> wrote:
>>> Does anyone have a clue why constructing subsets might be so slow?
>>>
>>> $ sage
>>> ----------------------------------------------------------------------
>>> | SAGE Version 2.8.5.1, Release Date: 2007-09-26                     |
>>> | Type notebook() for the GUI, and license() for information.        |
>>> ----------------------------------------------------------------------
>>>
>>> sage: %time x=list(Subsets(25,5))
>>> CPU times: user 15.01 s, sys: 1.02 s, total: 16.03 s
>>> Wall time: 39.74
>>> sage: %time x=list(Subsets(25,5))
>>> CPU times: user 21.90 s, sys: 0.36 s, total: 22.26 s
>>> Wall time: 23.85
>>>
>>> In Mathematica:
>>> $ math
>>> Mathematica 6.0 for Linux x86 (32-bit)
>>> Copyright 1988-2007 Wolfram Research, Inc.
>>>
>>> In[1]:= Timing[Subsets[Range[25], {5}];]
>>>
>>> Out[1]= {0.028001, Null}
>>>
>>>
>>> Is it the calls to GAP that are consuming all the time?  If so, I'll try
>>> to submit a patch that does subset enumeration natively in Python.
> 
> I haven't really spent a whole lot of time into optimizing certain
> areas -- I was mostly trying to get lots of features added then then
> optimize them.  Right now the chain looks like Subsets -> Subwords ->
> Combinations -> GAP which is pretty awful.  I've fixed it, and it'll
> be in 2.8.6.
> 
> sage: time a = Subsets(25, 5).list()
> CPU times: user 0.78 s, sys: 0.06 s, total: 0.85 s
> Wall time: 0.86
> sage: len(a)
> 53130
> 


Wow, that's great!  I realize you've had a monumental task in putting
all of the functionality there, even without optimizing things.  Your
work is much appreciated!

David: I thought GAP had something to do with something because I
profiled the function call and it showed a huge amount of time in some
routines that were obviously gap-related.  Also, every time I quit, SAGE
said that it was terminating a GAP session :).

With this fix, the function I was writing will be about 10 times faster
than the Mathematica equivalent on my test case instead of just being
the same speed as Mathematica :).  Thanks!

Mathematica is still ~20x faster (.04 seconds for the code above), but
now things are much more usable in SAGE.  Mathematica also seems to
generate things in a "nice" order, but those issues can be projects for
another day.

-Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to