[Python-Dev] Caching function pointers in type objects

Collin Winter collinwinter at google.com
Wed Mar 3 23:34:44 CET 2010


Hey Daniel,

On Wed, Mar 3, 2010 at 1:24 PM, Daniel Stutzbach
<daniel at stutzbachenterprises.com> wrote:
> On Tue, Mar 2, 2010 at 9:06 PM, Reid Kleckner <rnk at mit.edu> wrote:
>>
>> I don't think this will help you solve your problem, but one thing
>> we've done in unladen swallow is to hack PyType_Modified to invalidate
>> our own descriptor caches.  We may eventually want to extend that into
>> a callback interface, but it probably will never be considered an API
>> that outside code should depend on.
>
> Thanks Reid and Benjamin for the information.
>
> I think I see a way to dramatically speed up PyObject_RichCompareBool when
> comparing immutable, built-in, non-container objects (int, float, str,
> etc.).  It would speed up list.sort when the key is one of those types, as
> well as most operations on the ubiquitous dictionary with str keys.

That definitely sounds worth pursuing.

> Is that a worthwhile avenue to pursue, or is it likely to be redundant with
> Unladen Swallow's optimizations?

I don't believe it will be redundant with the optimizations in Unladen Swallow.

> If I can find time to pursue it, would it be best for me to implement it as
> a patch to Unladen Swallow, CPython trunk, or CPython py3k?

I would recommend patching py3k, with a backport to trunk.

Thanks,
Collin Winter


More information about the Python-Dev mailing list