[Python-ideas] Keep free list of popular iterator objects

Kyle Fisher anthonyfk at gmail.com
Sun Sep 15 21:19:30 CEST 2013


Well, don't I feel the fool. Thanks. :-)

-Kyle
On 2013-09-15 1:18 PM, "Tim Peters" <tim.peters at gmail.com> wrote:

> [ Kyle Fisher]
> > ...
> > Even if the iterator freelist isn't in first-level cache, I'm almost
> certain
> > it would exist within last-level cache.  Do you know what the cost of
> > fetching from this is compared to grabbing a lock like the current
> > _Py_Malloc does?
>
> It's infinitely more expensive than grabbing a lock ;-)  As Antoine
> noted earlier in this thread, while obmalloc.c is sprinkled with
> LOCK() and UNLOCK() macros, they all expand  to "nothing" - obmalloc.c
> doesn't actually grab any locks (it relies on the GIL to serialize
> threads).
>
> For example, LOCK is defined thusly:
>
> #define LOCK()          SIMPLELOCK_LOCK(_malloc_lock)
>
> and above that there's:
>
> #define SIMPLELOCK_LOCK(lock)   /* acquire released lock */
>
> Just FYI ;-)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130915/2624d563/attachment-0001.html>


More information about the Python-ideas mailing list