On Wed, Oct 22, 2008 at 3:51 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> Aside from list specialization versus a general iterator
> protocol, there is no fat in the min/max implementation.
> It loops, it compares, it returns.
>
> Also, a primary use case for min/max is with just two inputs.
Raymond Hettinger rcn.com> writes:
>
> If we wanted to go the distance and type specialize,
> it is possible to use the same ideas that used in
> Py2.6's builtin sum() to speed-up compares for particular types.
Would it be useful to create a macro that packs some of the optimizations in
http://b
nt: Wednesday, October 22, 2008 1:37 PM
Subject: Re: [Python-Dev] heapq, min and max
I
Kt just occurred to me:
Even though l.sort() is sorting a presorted array, it still must be doing
1-1 RichCompares minimum, just like max. So how do we explain the
large difference?
-Original Mess
; Of Antoine Pitrou
> Sent: Wednesday, October 22, 2008 14:06
> To: python-dev@python.org
> Subject: Re: [Python-Dev] heapq, min and max
>
> Kristján Valur Jónsson ccpgames.com> writes:
> > timeit.Timer("(l.sort(), l[-1])",
> > s).timeit(1000)
> >
> &
Kristján Valur Jónsson wrote:
Ok. And sorry, I missed your part about heapq now having a c implementation.
This is indeed good, I was misled by the presence of heapq.py.
Duplicate Python/C code will probably become more common. Even if the
Python is not used for prototyping (which I believe
I have submitted a patch for min() and max():
http://bugs.python.org/issue4174
> -Original Message-
> >
> > It depends on the added code complexity. In any case, you should open
> > an entry
> > on the tracker and post your patch there.
___
P
e the difference.
K
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf
> Of Antoine Pitrou
> Sent: Wednesday, October 22, 2008 14:41
> To: python-dev@python.org
> Subject: Re: [Python-Dev] heapq, min and max
>
> Kristján Val
Kristján Valur Jónsson ccpgames.com> writes:
>
> 0.39713821814841893 (old)
> 0.35184029691278162 (hakced, for special list treatment)
>
> So, there is a 12% performance boost to be had by specializing for lists.
> How about it?
It depends on the added code complexity. In any case, you shoul
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf
> Of Antoine Pitrou
> Sent: Wednesday, October 22, 2008 14:06
> To: python-dev@python.org
> Subject: Re: [Python-Dev] heapq, min and max
>
> This is clearly wrong. l.sort() will sort t
Kristján Valur Jónsson ccpgames.com> writes:
> timeit.Timer("(l.sort(), l[-1])",
> s).timeit(1000)
>
> 0.29406761513791935
This is clearly wrong. l.sort() will sort the list in place when it is first
invoked, and therefore will be very fast in subsequent calls.
Compare with:
timeit.Timer("
Hello there.
I was surprised to find recently that the heapq module is still a pure python
implementation.
A few years ago we wrote our own in C for use in Eve-online, and we usually do a
import blue.heapq as heapq.
Having a python implementation of it almost completely negates any benefit of
usi
11 matches
Mail list logo