[Python-ideas] Keep free list of popular iterator objects
Antoine Pitrou
solipsis at pitrou.net
Sun Sep 15 13:27:58 CEST 2013
On Sat, 14 Sep 2013 23:04:53 -0600
Kyle Fisher <anthonyfk at gmail.com> wrote:
> On Sat, Sep 14, 2013 at 9:28 PM, Raymond Hettinger <
> raymond.hettinger at gmail.com> wrote:
>
> >
> > It is surprising that you saw any performance gain at all.
> >
> > Python already has a default Python freelist scheme
> > in the _PyObject_Malloc() function in Objects/obmalloc.c.
> >
> > Another thought is that this isn't an inner-loop optimization.
> > The O(1) time for iterator creation is dominated by the O(n)
> > time to actually iterate over the dict keys, values, and items.
> >
> > Raymond
> >
>
>
> Hi Raymond,
>
> Taking a look at _PyObject_Malloc in Objects/obmalloc.c, I see that it
> needs to do some lock and unlock operations.
Please read carefully. The lock and unlock "operations" are no-ops.
Regards
Antoine.
More information about the Python-ideas
mailing list