mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Issue #19087: Improve bytearray allocation in order to allow cheap popping of data at the front (slice deletion).
This commit is contained in:
parent
dcd01b4932
commit
5df8a8a1fd
5 changed files with 182 additions and 151 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue