[issue4445] String allocations waste 3 bytes of memory on average.

2008-12-06 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Applied to py3k in r67610. -- status: open -> closed ___ Python tracker <[EMAIL PROTECTED]> ___ __

[issue4445] String allocations waste 3 bytes of memory on average.

2008-12-05 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Applied to the trunk in r67601. Will merge to other branches if the buildbots look okay. ___ Python tracker <[EMAIL PROTECTED]> ___ _

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Looks much cleaner. -- assignee: -> marketdickinson resolution: -> accepted versions: +Python 3.0 ___ Python tracker <[EMAIL PROTECTED]>

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Hmmm. test_sys fails on 64-bit build. Patch updated to fix this. All tests now pass on 32-bit and 64-bit, debug and non-debug builds. Added file: http://bugs.python.org/file12149/string_alloc.patch ___ P

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Mark Dickinson
Changes by Mark Dickinson <[EMAIL PROTECTED]>: Removed file: http://bugs.python.org/file12148/string_alloc.patch ___ Python tracker <[EMAIL PROTECTED]> ___

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Christian Heimes
Christian Heimes <[EMAIL PROTECTED]> added the comment: Ah! I forgot the trailing \0 byte ... Thanks Mark! ___ Python tracker <[EMAIL PROTECTED]> ___ ___

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: The +1 is there for the trailing null byte on the string: if s is a Python string with len(s) == n, then the ob_sval array needs space for n+1 characters. ___ Python tracker <[EMAIL PROTECTED]>

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Christian Heimes
Christian Heimes <[EMAIL PROTECTED]> added the comment: Why is +1 required here? If I understand offsetof() correctly than it returns the position of the ob_sval element. Shouldn't PyStringObject + offsetof(PyStringObject, ob_sval) point to the first element of the ob_svall array? -- nos

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Mark Dickinson
Changes by Mark Dickinson <[EMAIL PROTECTED]>: Removed file: http://bugs.python.org/file12141/string_alloc.patch ___ Python tracker <[EMAIL PROTECTED]> ___

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-28 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Yep. That works nicely. Here's a revised patch. Added file: http://bugs.python.org/file12148/string_alloc.patch ___ Python tracker <[EMAIL PROTECTED]> _

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-27 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Suggestion: #define PyStringObject_SIZE (offsetof(PyStringObject, ob_sval) + 1) /* Inline PyObject_NewVar */ - op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); /* Inline PyObject_NewVar */ +

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-27 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: +1 on the idea. -1 on the current patch. Can you encapsulate this in a simpler macro? I find the proposed replacement to be cryptic and error-prone (i.e. hard to mentally verify its correctness and somewhat likely to be screwed-up by a f

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-27 Thread Mark Dickinson
Changes by Mark Dickinson <[EMAIL PROTECTED]>: Removed file: http://bugs.python.org/file12140/string_alloc.patch ___ Python tracker <[EMAIL PROTECTED]> ___

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-27 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Updated patch: fix overflow checks to use offsetof instead of sizeof as well. Added file: http://bugs.python.org/file12141/string_alloc.patch ___ Python tracker <[EMAIL PROTECTED]>

[issue4445] String allocations waste 3 bytes of memory on average.

2008-11-27 Thread Mark Dickinson
New submission from Mark Dickinson <[EMAIL PROTECTED]>: There are a number of places in Objects/stringobject.c where memory is allocated for a string of length n using: PyObject_MALLOC(sizeof(PyStringObject) + n) On my computer (OS X 10.5.5/Intel), and, I suspect, on most common platforms, th