Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Daniel Stutzbach
On Tue, Mar 2, 2010 at 9:06 PM, Reid Kleckner r...@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

Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Benjamin Peterson
2010/3/3 Daniel Stutzbach dan...@stutzbachenterprises.com: 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

Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Daniel Stutzbach
On Wed, Mar 3, 2010 at 3:29 PM, Benjamin Peterson benja...@python.orgwrote: 2010/3/3 Daniel Stutzbach dan...@stutzbachenterprises.com: I think I see a way to dramatically speed up PyObject_RichCompareBool when comparing immutable, built-in, non-container objects (int, float, str, etc.).

Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Collin Winter
Hey Daniel, On Wed, Mar 3, 2010 at 1:24 PM, Daniel Stutzbach dan...@stutzbachenterprises.com wrote: On Tue, Mar 2, 2010 at 9:06 PM, Reid Kleckner r...@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

Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Daniel Stutzbach
On Wed, Mar 3, 2010 at 4:34 PM, Collin Winter collinwin...@google.comwrote: I would recommend patching py3k, with a backport to trunk. After thinking it over, I'm inclined to patch trunk, so I can run the Unladen Swallow macro-benchmarks, then forward-port to py3k. I'm correct in

Re: [Python-Dev] Caching function pointers in type objects

2010-03-03 Thread Collin Winter
On Wed, Mar 3, 2010 at 2:41 PM, Daniel Stutzbach dan...@stutzbachenterprises.com wrote: On Wed, Mar 3, 2010 at 4:34 PM, Collin Winter collinwin...@google.com wrote: I would recommend patching py3k, with a backport to trunk. After thinking it over, I'm inclined to patch trunk, so I can run

[Python-Dev] Caching function pointers in type objects

2010-03-02 Thread Daniel Stutzbach
In CPython, is it safe to cache function pointers that are in type objects? For example, if I know that some_type-tp_richcompare is non-NULL, and I call it (which may execute arbitrary user code), can I assume that some_type-tp_richcompare is still non-NULL? -- Daniel Stutzbach, Ph.D. President,

Re: [Python-Dev] Caching function pointers in type objects

2010-03-02 Thread Benjamin Peterson
2010/3/2 Daniel Stutzbach dan...@stutzbachenterprises.com: In CPython, is it safe to cache function pointers that are in type objects? For example, if I know that some_type-tp_richcompare is non-NULL, and I call it (which may execute arbitrary user code), can I assume that

Re: [Python-Dev] Caching function pointers in type objects

2010-03-02 Thread Reid Kleckner
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