[Python-checkins] CVS: python/dist/src/Include stringobject.h,2.32,2.33

Tim Peters tim_one@users.sourceforge.net
Thu, 28 Mar 2002 19:29:09 -0800


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv21495/python/Include

Modified Files:
	stringobject.h 
Log Message:
Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols.


Index: stringobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/stringobject.h,v
retrieving revision 2.32
retrieving revision 2.33
diff -C2 -d -r2.32 -r2.33
*** stringobject.h	23 Oct 2001 02:21:03 -0000	2.32
--- stringobject.h	29 Mar 2002 03:29:07 -0000	2.33
***************
*** 25,50 ****
  */
  
! /* Two speedup hacks.  Caching the hash saves recalculation of a
!    string's hash value.  Interning strings (which requires hash
!    caching) tries to ensure that only one string object with a given
!    value exists, so equality tests are one pointer comparison.
!    Together, these can speed the interpreter up by as much as 20%.
!    Each costs the size of a long or pointer per string object.  In
!    addition, interned strings live until the end of times.  If you are
!    concerned about memory footprint, simply comment the #define out
!    here (and rebuild everything!). */
! #define CACHE_HASH
! #ifdef CACHE_HASH
! #define INTERN_STRINGS
! #endif
  
  typedef struct {
      PyObject_VAR_HEAD
- #ifdef CACHE_HASH
      long ob_shash;
- #endif
- #ifdef INTERN_STRINGS
      PyObject *ob_sinterned;
- #endif
      char ob_sval[1];
  } PyStringObject;
--- 25,40 ----
  */
  
! /* Caching the hash (ob_shash) saves recalculation of a string's hash value.
!    Interning strings (ob_sinterned) tries to ensure that only one string
!    object with a given value exists, so equality tests can be one pointer
!    comparison.  This is generally restricted to strings that "look like"
!    Python identifiers, although the intern() builtin can be used to force
!    interning of any string.
!    Together, these sped the interpreter by up to 20%. */
  
  typedef struct {
      PyObject_VAR_HEAD
      long ob_shash;
      PyObject *ob_sinterned;
      char ob_sval[1];
  } PyStringObject;
***************
*** 71,83 ****
  						  int, char**, int*);
  
- #ifdef INTERN_STRINGS
  extern DL_IMPORT(void) PyString_InternInPlace(PyObject **);
  extern DL_IMPORT(PyObject *) PyString_InternFromString(const char *);
  extern DL_IMPORT(void) _Py_ReleaseInternedStrings(void);
- #else
- #define PyString_InternInPlace(p)
- #define PyString_InternFromString(cp) PyString_FromString(cp)
- #define _Py_ReleaseInternedStrings()
- #endif
  
  /* Macro, trading safety for speed */
--- 61,67 ----