summaryrefslogtreecommitdiffstats
path: root/Modules/_struct.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)Victor Stinner2021-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pycore_moduleobject.h internal header file with static inline functions to access module members: * _PyModule_GetDict() * _PyModule_GetDef() * _PyModule_GetState() These functions don't check at runtime if their argument has a valid type and can be inlined even if Python is not built with LTO. _PyType_GetModuleByDef() uses _PyModule_GetDef(). Replace PyModule_GetState() with _PyModule_GetState() in the extension modules, considered as performance sensitive: * _abc * _functools * _operator * _pickle * _queue * _random * _sre * _struct * _thread * _winapi * array * posix The following extensions are now built with the Py_BUILD_CORE_MODULE macro defined, to be able to use the internal pycore_moduleobject.h header: _abc, array, _operator, _queue, _sre, _struct.
* Use Py_NewRef in Modules/_struct.c (GH-23981)Pablo Galindo2020-12-281-2/+1
|
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-011-3/+3
| | | | | | | | | | | No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
* bpo-1635741: Fix _struct for build bot error (GH-23402)Dong-hee Na2020-11-191-1/+1
| | | Automerge-Triggered-By: GH:tiran
* bpo-1635741: Port _struct to multiphase initialization (GH-23398)Christian Heimes2020-11-191-233/+265
| | | Signed-off-by: Christian Heimes <christian@python.org>
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-281-1/+1
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for ↵Pablo Galindo2020-05-271-0/+1
| | | | | | | | | PyType_FromSpec types (reverts GH-19414) (GH-20264) Heap types now always visit the type in tp_traverse. See added docs for details. This reverts commit 0169d3003be3d072751dd14a5c84748ab63a249f. Automerge-Triggered-By: @encukou
* bpo-35714: Reject null characters in struct format strings (GH-16928)Zackery Spytz2020-05-251-0/+5
| | | | struct.error is now raised if there is a null character in a struct format string.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. ↵Serhiy Storchaka2020-04-121-2/+2
| | | | (GH-19472)
* bpo-39689: Do not use native packing for format "?" with standard size ↵Stefan Krah2020-03-241-0/+3
| | | | (GH-18969)
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-11/+23
| | | | functions (GH-19017)
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-171-1/+1
|
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-38140: Make dict and weakref offsets opaque for C heap types (#16076)Eddie Elizondo2019-09-191-1/+1
| | | | | | * Make dict and weakref offsets opaque for C heap types * Add news
* bpo-37752: Delete redundant Py_CHARMASK in normalizestring() (GH-15095)Jordon Xu2019-09-101-2/+2
|
* bpo-38076: Make struct module PEP-384 compatible (#15805)Dino Viehland2019-09-101-147/+172
| | | | | | | | | | * PEP-384 _struct * More PEP-384 fixes for _struct Summary: Add a couple of more fixes for `_struct` that were previously missed such as removing `tp_*` accessors and using `PyBytesWriter` instead of calling `PyBytes_FromStringAndSize` with `NULL`. Also added a test to confirm that `iter_unpack` type is still uninstantiable. * 📜🤖 Added by blurb_it.
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * Fix typos in comments, docs and test names * Update test_pyparse.py account for change in string length * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: Dealloccte -> Deallocate Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Update posixmodule checksum. * Reverse idlelib changes.
* bpo-37483: add _PyObject_CallOneArg() function (#14558)Jeroen Demeyer2019-07-041-1/+1
|
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-4/+4
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)Serhiy Storchaka2019-02-251-1/+4
|
* bpo-23867: Argument Clinic: inline parsing code for a single positional ↵Serhiy Storchaka2018-12-251-6/+6
| | | | parameter. (GH-9689)
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-4/+4
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-1/+1
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-30249: Improve struct.unpack_from() error messages (GH-6059)Xiang Zhang2018-03-101-6/+29
|
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-151-5/+5
| | | | arguments. (#4746)
* bpo-30246: fix several error messages which only mention bytes in struct (#1421)Xiang Zhang2017-09-141-4/+5
|
* bpo-31095: fix potential crash during GC (GH-2974)INADA Naoki2017-08-241-0/+2
|
* bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka2017-07-031-20/+6
| | | | | the bare METH_FASTCALL be used for functions with positional-only parameters.
* bpo-21071: struct.Struct.format type is now str (#845)Victor Stinner2017-06-231-2/+2
|
* bpo-20627: Fix error message when keyword arguments are used (#2115)Sylvain2017-06-151-6/+14
|
* bpo-30245: Fix possible overflow when organize struct.pack_into error ↵Johan Liu2017-06-021-2/+5
| | | | message (#1682)
* bpo-30242: resolve some undefined behaviours in struct (#1418)Xiang Zhang2017-05-151-5/+9
|
* bpo-30224: remove outdated checks in struct (#1374)Xiang Zhang2017-05-151-47/+15
|
* bpo-29802: Fix reference counting in module-level struct functions (#1213)Serhiy Storchaka2017-04-201-0/+1
| | | | when pass arguments of wrong type.
* bpo-29649: Improve struct.pack_into() boundary error messages (#424)Andrew Nester2017-04-041-4/+30
|
* Issue #29300: Use Argument Clinic for getting struct object from the format.Serhiy Storchaka2017-02-041-65/+52
|
* Rename struct.unpack() 2nd parameter to "buffer"Victor Stinner2017-02-021-4/+4
| | | | | | | | | | Issue #29300: Rename struct.unpack() second parameter from "inputstr" to "buffer", and use the Py_buffer type. Fix also unit tests on struct.unpack() which passed a Unicode string instead of a bytes string as struct.unpack() second parameter. The purpose of test_trailing_counter() is to test invalid format strings, not to test the buffer parameter.
* Issue #29300: Convert _struct module to Argument ClinicVictor Stinner2017-02-021-226/+246
| | | | | | | | | | | | | | | | | | | | | | | | | * The struct module now requires contiguous buffers. * Convert most functions and methods of the _struct module to Argument Clinic * Use "Py_buffer" type for the "buffer" argument. Argument Clinic is responsible to create and release the Py_buffer object. * Use "PyStructObject *" type for self to avoid explicit conversions. * Add an unit test on the _struct.Struct.unpack_from() method to test passing arguments as keywords. * Rephrase docstrings. * Rename "fmt" argument to "format" in docstrings and the documentation. As a side effect, functions and methods which used METH_VARARGS calling convention like struct.pack() now use the METH_FASTCALL calling convention which avoids the creation of temporary tuple to pass positional arguments and so is faster. For example, struct.pack("i", 1) becomes 1.56x faster (-36%):: $ ./python -m perf timeit \ -s 'import struct; pack=struct.pack' 'pack("i", 1)' \ --compare-to=../default-ref/python Median +- std dev: 119 ns +- 1 ns -> 76.8 ns +- 0.4 ns: 1.56x faster (-36%) Significant (t=295.91) Patch co-written with Serhiy Storchaka.
* Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-1/+1
| | | | dict.
* Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-1/+1
| | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-1/+1
| | | | | | | | | | | | | | * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
* Closes #21124, #28337: Call PyType_Ready on unpackiter_type.Zachary Ware2016-10-041-0/+3
| | | | Patch by Masayuki Yamamoto.
* Issue #21124: Fix building _struct on Cygwin.Zachary Ware2016-10-021-1/+1
| | | | Patch by Masayuki Yamamoto.
* merge 3.5 (#28184)Benjamin Peterson2016-09-201-1/+1
|\
* | require C99 boolBenjamin Peterson2016-09-071-12/+5
| |
* | replace PY_LONG_LONG with long longBenjamin Peterson2016-09-061-26/+26
| |
* | require a long long data type (closes #27961)Benjamin Peterson2016-09-061-43/+0
| |
* | Issue #11734: Add support for IEEE 754 half-precision floats to the struct ↵Mark Dickinson2016-09-031-1/+75
| | | | | | | | module. Original patch by Eli Stevens.
* | merge headsGregory P. Smith2016-04-151-8/+8
|\ \ | |/