[Python-ideas] Parametrized any() and all() ?
Nick Coghlan
ncoghlan at gmail.com
Fri Jan 18 13:52:58 CET 2013
On Fri, Jan 18, 2013 at 10:30 PM, Tarek Ziadé <tarek at ziade.org> wrote:
> On 1/16/13 7:47 PM, Antoine Pitrou wrote:
>>
>> You know, discussing performance without posting benchmark numbers is
>> generally pointless.
>
>
> Sure, yes, so I tried to implement it by adapting the current any() :
>
> http://tarek.pastebin.mozilla.org/2068630
>
> but it is 20% slower in my benchmark. However, I have no idea if my
> implementation is the right way to do things.
Resuming an existing frame (i.e. using a generator expression) is
almost always going to be faster than going through the argument
passing machinery and initialising a *new* frame. Chaining C level
iterators together (e.g. map, itertools) is even faster.
DSU is great for cases where you need it, but a transformation
pipeline is otherwise likely to be faster (or at least not
substantially slower).
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list