This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jnferguson
Recipients belopolsky, gregory.p.smith, jnferguson, lemburg, nnorwitz
Date 2008-04-12.12:13:54
SpamBayes Score 0.005341134
Marked as misclassified No
Message-id <1208002437.62.0.160678369948.issue2620@psf.upfronthosting.co.za>
In-reply-to
Content
Additionally-- the PyMem_NEW()/PyMem_New() macro's need to be fixed:

 231 static
 232 PyUnicodeObject *_PyUnicode_New(Py_ssize_t length)
 233 {
 234     register PyUnicodeObject *unicode;
 235 
 236     /* Optimization for empty strings */
 237     if (length == 0 && unicode_empty != NULL) {
 238         Py_INCREF(unicode_empty);
 239         return unicode_empty;
 240     }
 241 
 242     /* Unicode freelist & memory allocation */
 243     if (unicode_freelist) {
 244         unicode = unicode_freelist;
 245         unicode_freelist = *(PyUnicodeObject **)unicode;
 246         unicode_freelist_size--;
 247         if (unicode->str) {
 248             /* Keep-Alive optimization: we only upsize the buffer,
 249                never downsize it. */
 250             if ((unicode->length < length) &&
 251                 unicode_resize(unicode, length) < 0) {
 252                 PyMem_DEL(unicode->str);
 253                 goto onError;
 254             }
 255         }
 256         else {
 257             unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
 258         }

 85 #define PyMem_New(type, n) \
 86   ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
 87         ( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
 88 #define PyMem_NEW(type, n) \
 89   ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
 90         ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
 91 
 92 #define PyMem_Resize(p, type, n) \
 93   ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
 94         ( (p) = (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) )
 95 #define PyMem_RESIZE(p, type, n) \
 96   ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
 97         ( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) )


It looks like much of this is reachable from modules, unicode objects,
dict objects, set objects, et cetera. Also, if a 2G string across the
network seems unrealistic consider what 2 billion A's compresses down
to.(Macros again taken from 2.5.2 vanilla)
History
Date User Action Args
2008-04-12 12:13:57jnfergusonsetspambayes_score: 0.00534113 -> 0.005341134
recipients: + jnferguson, lemburg, nnorwitz, gregory.p.smith, belopolsky
2008-04-12 12:13:57jnfergusonsetspambayes_score: 0.00534113 -> 0.00534113
messageid: <1208002437.62.0.160678369948.issue2620@psf.upfronthosting.co.za>
2008-04-12 12:13:56jnfergusonlinkissue2620 messages
2008-04-12 12:13:54jnfergusoncreate