Shawn Walker wrote: > >However, I wonder if you'd considered using the PyString_Intern* > >functions instead of writing your own dictionary. Looks like at > >least one other person went down this road first, too: > > > > http://jjinux.blogspot.com/2008/08/python-intern.html > > I did, but I saw the warning that they've been removed in Python 3.x > (not that we strictly care about python 3.x). See below for an > additional motivation.
I'd figured that they'd simply disappeared because strings all become unicode objects, and that the functions became something else. Looks like PyUnicode_Intern*() exist in 3.1, even if they don't in 2.6. > However, my main motivation for avoiding reliance on the CPython API > was that not all of our action parsing is done in CPython. By using > a dictionary, I can share the attribute strings with any Python code > that does action parsing, such as internalizelist(). You could use intern() in those cases, no? > Another motivation I had was that doing the caching using a global > dict bypasses the early collection, and avoids re-allocation later. > From what I've read, the behaviour of string interning has changed > off and on in CPython, and I want to control the behaviour of when > these strings are garbage collected. Okay. > Across an install of redistributable, only 45 unique action attributes > exist, so as you might imagine, this dictionary is pretty small. Sounds good. > >If that doesn't work, does using a set instead of a dictionary help > >things at all? > > I thought about using a set, but I don't see any methods to retrieve a > specific entry from a set so that I could re-use it. It looks like I'd > have to iterate over it to find my entry again, and that seemed slow. How weird. Thanks, Danek _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
