OK, I will add it to compatibility.

On 27 May 2012 23:35, Aaron Meurer <[email protected]> wrote:
> On May 27, 2012, at 2:59 PM, "Vladimir Perić" <[email protected]> wrote:
>
>> On Sun, May 27, 2012 at 10:30 PM, [email protected]
>> <[email protected]> wrote:
>>> In python2.5 set.union requires exactly two arguments. In other
>>> versions it requires any positive number of arguments. Are you aware
>>> of idiomatic way to do this in python2.5
>>>
>>> set.union(set1, set2, set3)
>>>
>>> If not I will probably end up using reduce.
>>
>> You could also introduce the appropriate code to
>> sympy.core.compatibility if it makes it much easier for you, but I
>> guess using reduce() in this case is completely ok.
>
> Another advantage of doing it this way is that you can make the helper
> function use set.union in Python 2.6+, which is probably more
> efficient. It also lets us get an idea of what Python features we're
> missing just by looking at what's been defined in the compatibility
> file.
>
> Actually, if I think about it, a more efficient way would probably be
> to create a new set and to iteratively add the elements of the other
> sets.  This is better because it uses the mutability of set(), whereas
> reduce with set.union would create a new set at each pass. So
> something like
>
> def set_union:
>    ret = set()
>    for s in sets:
>        ret |= s
>    return ret
>
> might be more efficient than reduce(set.union, sets, set()). You'll
> have to time it to double check, though.
>
> You might also think about if you can just use the mutability in your
> application.
>
> Aaron Meurer
>
>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "sympy" group.
>>> 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/sympy?hl=en.
>>>
>>
>>
>>
>> --
>> Vladimir Perić
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "sympy" group.
>> 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/sympy?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> 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/sympy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to