[Patches] [ python-Patches-593627 ] Static names
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 11 Aug 2002 07:46:14 -0700
Patches item #593627, was opened at 2002-08-11 06:41
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=593627&group_id=5470
Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Oren Tirosh (orenti)
Assigned to: Nobody/Anonymous (nobody)
Summary: Static names
Initial Comment:
This patch creates static string objects for all built-in
names and interns then on initialization. The macro
PyNAME is be used to access static names.
PyNAME(__spam__) is equivalent to
PyString_InternFromString("__spam__") but is a
constant expression. It requires the name to be one of
the built-in names. A linker error will be generated if it
isn't.
Most conversions of C strings into temporary string
objects can be eliminated (PyString_FromString,
PyString_InternFromString). Most string comparisons at
runtime can also be eliminated.
Instead of :
if (strcmp(PyString_AsString(name), "__spam__")) ...
This code can be used:
PyString_INTERN(name)
if (name == PyNAME(__spam__)) ...
Where PyString_INTERN is a fast inline check if the
string is already interned (and it usually is). To prevent
unbounded accumulation of interned strings the mortal
interned string patch should also be applied.
The patch converts most of the builtin module to this
new mode as an example.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-08-11 10:46
Message:
Logged In: YES
user_id=33168
Couple of initial comments:
* this is a reverse patch
* it seems like there are other changes in here
- int ob_shash -> long
- releasing interned strings?
* dictobject.c is removed?
* including python headers should use "" not <>
Oren, could you generate a new patch with only the changes
to support PyNAME? Thanks!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=593627&group_id=5470