This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, belopolsky, neologix, python-dev, rhettinger, tim.peters, vstinner
Date 2013-11-21.12:24:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385036672.8.0.307552906516.issue18874@psf.upfronthosting.co.za>
In-reply-to
Content
"Reuse _Py_hashtable for the methods cache is not trivial, the API doesn't fit exactly. I didn't spend much time to try to adapt _Py_hashtable API or the methods cache."

I don't understand which part is the key and which part is the enetry data in method_cache_entry structure:

struct method_cache_entry {
    unsigned int version;
    PyObject *name;             /* reference to exactly a str or None */
    PyObject *value;            /* borrowed */
};

_PyType_Lookup() compares name and version. Does it mean that version is part of the key?

If it's possible to only store name as the key and store version and value in the data, it would be simple to reuse _Py_hashtable. I guess that it would be possible to get a cache entry using the name and later compare the version, it the version doesn't match: don't use the cache. It would require to copy the data (version+value: short structure, a few bytes) from the hash table entry to a local variable (allocated in the stack).
History
Date User Action Args
2013-11-21 12:24:32vstinnersetrecipients: + vstinner, tim.peters, rhettinger, amaury.forgeotdarc, belopolsky, neologix, python-dev
2013-11-21 12:24:32vstinnersetmessageid: <1385036672.8.0.307552906516.issue18874@psf.upfronthosting.co.za>
2013-11-21 12:24:32vstinnerlinkissue18874 messages
2013-11-21 12:24:32vstinnercreate