On 04/ 2/10 06:17 PM, Danek Duvall wrote:
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.
Yes and no. 8-bit strings use PyBytes by default as I understand it,
which doesn't support intern, so unless you explicitly use Unicode()
objects for all strings you don't get this. But perhaps I'm
misunderstanding...
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?
Ah, I wasn't aware of that function at all -- I thought only the CPython
API had it.
So then, if the garbage collection and slight additional savings in
memory usage don't justify it, would you prefer I just use intern()
instead of the dict?
I have no strong preference here in light of intern(), although I remain
uncertain about the garbage collection aspects of it.
-Shawn
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss