diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-05 19:12:18 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-05 19:12:18 (GMT) |
commit | 5df8a8a1fd6cc6f4469dc7d3994d06e2aea24c52 (patch) | |
tree | 3e56cec37fe9182adb7ae56eacdc68149dfb1981 /Include | |
parent | dcd01b49329d5596c3ad3254ae9eeabd15f100d2 (diff) | |
download | cpython-5df8a8a1fd6cc6f4469dc7d3994d06e2aea24c52.zip cpython-5df8a8a1fd6cc6f4469dc7d3994d06e2aea24c52.tar.gz cpython-5df8a8a1fd6cc6f4469dc7d3994d06e2aea24c52.tar.bz2 |
Issue #19087: Improve bytearray allocation in order to allow cheap popping of data at the front (slice deletion).
Diffstat (limited to 'Include')
-rw-r--r-- | Include/bytearrayobject.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Include/bytearrayobject.h b/Include/bytearrayobject.h index eccd44c..19e32a2 100644 --- a/Include/bytearrayobject.h +++ b/Include/bytearrayobject.h @@ -22,10 +22,11 @@ extern "C" { #ifndef Py_LIMITED_API typedef struct { PyObject_VAR_HEAD + Py_ssize_t ob_alloc; /* How many bytes allocated in ob_buffer */ + char *ob_bytes; /* Physical backing buffer */ + char *ob_start; /* Logical start inside ob_bytes */ /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ - int ob_exports; /* how many buffer exports */ - Py_ssize_t ob_alloc; /* How many bytes allocated */ - char *ob_bytes; + int ob_exports; /* How many buffer exports */ } PyByteArrayObject; #endif @@ -49,8 +50,8 @@ PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); #ifndef Py_LIMITED_API #define PyByteArray_AS_STRING(self) \ (assert(PyByteArray_Check(self)), \ - Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) -#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) + Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string) +#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self)) PyAPI_DATA(char) _PyByteArray_empty_string[]; #endif |