On Wednesday, December 5, 2012 2:59:59 PM UTC-8, Maarten Derickx wrote:
>
>
> Maybe we should overwrite the sum() function such that it behaves 
>> different for lists, since the command sum(entries,[]) looks much more 
>> clear and intuitive then the for loop.
>>
>
> It seems like the top level sum in sage is already optimized by doing some 
> binary tree balances sum stuff, so maybe just importing that sum in the 
> cyclotomic field code should also fix this performance issue.
>

No, list concatenation does not benefit from balanced trees. 
sum(entries,[]) should simply be spelled
L=[]
L.extend(itertools.chain(*entries))

You could put that as a special case in sum, but I'd hesitate to do that. 
Most python docs warn against using '+' on lists.

Sometimes it sucks that python has an aversion to being a properly 
functional language.

However, since at this point the expected lengths of all objects involved 
are known anyway, I don't think it should be necessary to construct any of 
these intermediate data structures. Just create the matrices to be 
initialized, loop through the list and write the entries into the right 
spots.

-- 
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