Skip to content

Commit 81fc2fe

Browse files
Specialize FOR_ITER_DICT_ITEMS
1 parent aa8578d commit 81fc2fe

17 files changed

Lines changed: 1607 additions & 1081 deletions

Include/internal/pycore_dict.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,17 @@ extern void _PyDict_EnablePerThreadRefcounting(PyObject *op);
344344

345345
PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *);
346346

347+
PyAPI_FUNC(PyObject *) _PyDictIter_IterNextItem(PyObject *self);
348+
349+
typedef struct {
350+
PyObject_HEAD
351+
PyDictObject *di_dict; /* Set to NULL when iterator is exhausted */
352+
Py_ssize_t di_used;
353+
Py_ssize_t di_pos;
354+
PyObject* di_result; /* reusable result tuple for iteritems */
355+
Py_ssize_t len;
356+
} _PyDictIterItemObject;
357+
347358
// See `_Py_INCREF_TYPE()` in pycore_object.h
348359
#ifndef Py_GIL_DISABLED
349360
# define _Py_INCREF_DICT Py_INCREF

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ Known values:
290290
Python 3.15a4 3657 (Add BINARY_OP_SUBSCR_USTR_INT)
291291
Python 3.15a4 3658 (Optimize bytecode for list/set called on genexp)
292292
Python 3.15a4 3659 (Add CALL_FUNCTION_EX specialization)
293+
Python 3.15a4 3660 (Add FOR_ITER_DICT_ITEMS specialization)
293294
294295
295296
Python 3.16 will start with 3700
@@ -303,7 +304,7 @@ PC/launcher.c must also be updated.
303304
304305
*/
305306

306-
#define PYC_MAGIC_NUMBER 3659
307+
#define PYC_MAGIC_NUMBER 3660
307308
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
308309
(little-endian) and then appending b'\r\n'. */
309310
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)