On 12/6/12 11:40 AM, Nils Bruin wrote:
On Thursday, December 6, 2012 2:18:45 AM UTC-8, Volker Braun wrote:

    I haven't checked this, but I suspect that the naive approach of
    making a copy of the zero matrix and then filling in the entries
    with set_unsafe in a loop will be faster.

Yes, whoever rewrites that should by all means try that first. Usually,
having no intermediate data structures beats constructing them efficiently.

Since we're looking at list concatenation anyway: I would have thought
the list comprehension and the itertools solution would be in the same
ballpark. The itertools solution turns out to be quite a bit faster!

Interesting. I would have thought the list comprehension would be faster too.

If entries isn't actually used as a list, but just iterated through, there's also no reason to explicitly make R. When the assignment into the matrix is done, you could just iterate through itertools.chain.

Thanks,

Jason


--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to