external modules & interned strings???

Courageous jkraska1 at san.rr.com
Wed May 24 00:01:44 EDT 2000


Looking over some C external modules of late, it has
occured to me that it ought to be possible to reach
back into python and to either obtain or create and
obtain python interned strings.

I've noticed, for example, that getattr often seems
to be implemented with strcmp. This seems like a
waisted step if you can always be assured that an
attr lookup string will be a pythonized interned
string. You could, for example, during your initmod
"register" the names of your attributes with python
(insuring their interned status), and then get hooks
to those interned values (yeah, don't mess with 'em),
and later when getattr is called just do pointer
compares to get to your attributes, saving the more
expensive strcmp function call.

Thoughts?







C/



More information about the Python-list mailing list