[Python-Dev] Keeping interned strings in a set

Raymond Hettinger rhettinger at ewtllc.com
Fri Jun 16 02:47:03 CEST 2006


Alexander Belopolsky wrote:

>As an exercise in using the new set C API, I've replaced the
>"interned" dictionary in stringobject.c with a set.  Surprisingly,
>what I thought would be a simple exercise, took several hours to
>implement and debug.  Two problems are worth mentioning:
>
>1. I had to add a function to setobject.h to retrieve a pointer to an
>object stored in a set. I could not find a way to do it using current
>API (short of iterating through the set of course).
>
>2. I had to change the  PyString_Fini() and PySet_Fini() in
>Py_Finalize() because cleaning "interned" set cannot be done after the
>set module is finalized.
>
>If there is any interest, I will submit a patch, but it does not seem
>to affect performance in any meaningful way.
>  
>

I would be curious to see your patch.


Raymond


More information about the Python-Dev mailing list