Skip to content

Commit 415bdf2

Browse files
committed
Version 0.13.0: Python 3.13 compatibility
Python 3.13 removed _PyArg_ParseStack and _PyDict_SetItem_KnownHash from the C API Unfortunately this means that the code has to resort to the old (not as optimized) approaches again. CI: - Update pypy build - Update python 3.12 build - Add python 3.13 rc2 build - update cibuildwheel
1 parent d3df1a7 commit 415bdf2

File tree

9 files changed

+72
-23
lines changed

9 files changed

+72
-23
lines changed

.github/workflows/cpython.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ jobs:
4545
uses: actions/checkout@v4
4646
with:
4747
fetch-depth: 1
48-
- name: Download Python 3.12
48+
- name: Download Python
4949
run: |
50-
wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgz -q
51-
python3 ci/verify_checksum.py Python-3.12.2.tgz 4e64a004f8ad9af1a75607cfd0d5a8c8
52-
- name: Install Python 3.12
50+
wget https://www.python.org/ftp/python/3.12.6/Python-3.12.6.tgz -q
51+
python3 ci/verify_checksum.py Python-3.12.6.tgz c2f1dd5c8807ee50b778684b7958ee28
52+
- name: Install Python
5353
run: |
54-
tar xzf Python-3.12.2.tgz
55-
cd Python-3.12.2
54+
tar xzf Python-3.12.6.tgz
55+
cd Python-3.12.6
5656
./configure --with-pydebug
5757
sudo make altinstall -s -j2
5858
- name: Remove download
5959
run: |
60-
sudo python3.12 -c "import os; os.remove('./Python-3.12.2.tgz'); import shutil; shutil.rmtree('./Python-3.12.2/')"
60+
sudo python3.12 -c "import os; os.remove('./Python-3.12.6.tgz'); import shutil; shutil.rmtree('./Python-3.12.6/')"
6161
- name: Install dependencies
6262
run: |
6363
python3.12 -m pip install pip setuptools wheel --upgrade --user --no-warn-script-location
@@ -77,6 +77,46 @@ jobs:
7777
run: |
7878
python3.12 -m pytest tests/
7979
80+
build-python3-13-with-debug:
81+
runs-on: ubuntu-latest
82+
timeout-minutes: 10
83+
steps:
84+
- name: Check out source
85+
uses: actions/checkout@v4
86+
with:
87+
fetch-depth: 1
88+
- name: Download Python
89+
run: |
90+
wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0rc2.tgz -q
91+
python3 ci/verify_checksum.py Python-3.13.0rc2.tgz ad7f44153649e27ec385e7633e853e03
92+
- name: Install Python
93+
run: |
94+
tar xzf Python-3.13.0rc2.tgz
95+
cd Python-3.13.0rc2
96+
./configure --with-pydebug
97+
sudo make altinstall -s -j2
98+
- name: Remove download
99+
run: |
100+
sudo python3.13 -c "import os; os.remove('./Python-3.13.0rc2.tgz'); import shutil; shutil.rmtree('./Python-3.13.0rc2/')"
101+
- name: Install dependencies
102+
run: |
103+
python3.13 -m pip install pip setuptools wheel --upgrade --user --no-warn-script-location
104+
- name: Create wheel
105+
run: |
106+
python3.13 -m pip wheel . --no-deps --wheel-dir=./wheelhouse/ -vv
107+
- name: Install package
108+
run: |
109+
python3.13 -m pip install iteration_utilities --no-index --find-links=./wheelhouse/ --user -vv
110+
- name: Import package
111+
run: |
112+
python3.13 -c "import iteration_utilities"
113+
- name: Install test dependencies
114+
run: |
115+
python3.13 -m pip install pytest --user --no-warn-script-location
116+
- name: Run tests
117+
run: |
118+
python3.13 -m pytest tests/
119+
80120
build-sdist:
81121
runs-on: ubuntu-latest
82122
timeout-minutes: 10
@@ -100,7 +140,7 @@ jobs:
100140
rm ./dist/*.whl
101141
- name: Install package
102142
run: |
103-
python -m pip install ./dist/iteration_utilities-0.12.1.tar.gz -vv
143+
python -m pip install ./dist/iteration_utilities-0.13.0.tar.gz -vv
104144
- name: Import package
105145
run: |
106146
python -c "import iteration_utilities"
@@ -132,7 +172,7 @@ jobs:
132172
python-version: '3.12'
133173

134174
- name: Install cibuildwheel
135-
run: python -m pip install cibuildwheel==2.16.5
175+
run: python -m pip install cibuildwheel==2.21.1
136176

137177
- name: Build wheels
138178
run: python -m cibuildwheel --output-dir wheelhouse

.github/workflows/pypy.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
- name: Test installation (Ubuntu)
2424
if: matrix.os == 'ubuntu-20.04'
2525
run: |
26-
python3 -c "import urllib.request; urllib.request.urlretrieve ('hhttps://downloads.python.org/pypy/pypy3.10-v7.3.15-linux64.tar.bz2', './pypy.tar.bz2')"
26+
python3 -c "import urllib.request; urllib.request.urlretrieve ('hhttps://downloads.python.org/pypy/pypy3.10-v7.3.17-linux64.tar.bz2', './pypy.tar.bz2')"
2727
python3 -c "import tarfile; tar = tarfile.open('./pypy.tar.bz2', 'r:bz2');tar.extractall('.'); tar.close()"
28-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -m ensurepip
29-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -m pip install pip setuptools --upgrade
30-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -m pip install . --no-deps -vv
31-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -c "import iteration_utilities"
32-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -m pip install pytest
33-
./pypy3.10-v7.3.15-linux64/bin/pypy3 -m pytest tests
28+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -m ensurepip
29+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -m pip install pip setuptools --upgrade
30+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -m pip install . --no-deps -vv
31+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -c "import iteration_utilities"
32+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -m pip install pytest
33+
./pypy3.10-v7.3.17-linux64/bin/pypy3 -m pytest tests

docs/CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog for "iteration_utilities"
22
-----------------------------------
33

4+
Version 0.13.0 (unreleased)
5+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
- Python 3.13 compatibility: A few optimizations are not possible anymore in Python 3.13.
8+
This means the performance of some functions (most notably ``groupedby``) will be slightly
9+
slower.
10+
11+
412
Version 0.12.1 (2024-03-03)
513
^^^^^^^^^^^^^^^^^^^^^^^^^^^
614

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "iteration_utilities"
7-
version = "0.12.1"
7+
version = "0.13.0"
88
description = "Utilities based on Pythons iterators and generators."
99
readme = "README.rst"
1010
requires-python = ">=3.7"

src/iteration_utilities/_iteration_utilities/_iteration_utilities.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static PyMethodDef PyIU_methods[] = {
156156
/* Helper */
157157
{
158158
"_parse_args", /* ml_name */
159-
#if PyIU_USE_VECTORCALL
159+
#if PyIU_USE_ARG_PARSE_STACK
160160
(PyCFunction)(void (*)(void))PyIU_TupleToList_and_InsertItemAtIndex, /* ml_meth */
161161
METH_FASTCALL, /* ml_flags */
162162
#else
@@ -167,7 +167,7 @@ static PyMethodDef PyIU_methods[] = {
167167
},
168168
{
169169
"_parse_kwargs", /* ml_name */
170-
#if PyIU_USE_VECTORCALL
170+
#if PyIU_USE_ARG_PARSE_STACK
171171
(PyCFunction)(void (*)(void))PyIU_RemoveFromDictWhereValueIs, /* ml_meth */
172172
METH_FASTCALL, /* ml_flags */
173173
#else

src/iteration_utilities/_iteration_utilities/exported_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ PyIU_parse_kwargs(PyObject *dct, PyObject *remvalue) {
101101
Py_RETURN_NONE;
102102
}
103103

104-
#if PyIU_USE_VECTORCALL
104+
#if PyIU_USE_ARG_PARSE_STACK
105105
PyObject *
106106
PyIU_TupleToList_and_InsertItemAtIndex(PyObject *Py_UNUSED(m), PyObject *const *args, size_t nargs) {
107107
PyObject *tup;

src/iteration_utilities/_iteration_utilities/exported_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99
#include <Python.h>
1010
#include "helpercompat.h"
1111

12-
#if PyIU_USE_VECTORCALL
12+
#if PyIU_USE_ARG_PARSE_STACK
1313
PyObject * PyIU_TupleToList_and_InsertItemAtIndex(PyObject *Py_UNUSED(m), PyObject *const *args, size_t nargs);
1414
PyObject * PyIU_RemoveFromDictWhereValueIs(PyObject *Py_UNUSED(m), PyObject *const *args, size_t nargs);
1515
#else

src/iteration_utilities/_iteration_utilities/groupedby.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include "groupedby.h"
66
#include "helper.h"
77

8-
#define PyIU_USE_DICT_INTERNALS PYIU_CPYTHON
9-
108
PyObject *
119
PyIU_Groupby(PyObject *Py_UNUSED(m), PyObject *args, PyObject *kwargs) {
1210
static char *kwlist[] = {"iterable", "key", "keep", "reduce", "reducestart", NULL};

src/iteration_utilities/_iteration_utilities/helpercompat.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ extern "C" {
4141
#define PyIU_USE_FASTCALL (PYIU_CPYTHON && PY_MAJOR_VERSION == 3 && (PY_MINOR_VERSION == 6 || PY_MINOR_VERSION == 7))
4242
#define PyIU_USE_UNDERSCORE_VECTORCALL (PYIU_CPYTHON && PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 8)
4343
#define PyIU_USE_VECTORCALL (PYIU_CPYTHON && ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || PY_MAJOR_VERSION >= 4))
44+
#define PyIU_USE_ARG_PARSE_STACK (PYIU_CPYTHON && (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8 && PY_MINOR_VERSION < 13)) // https://github.com/python/cpython/issues/110964
4445
#define PyIU_USE_BUILTIN_MODULE_ADDTYPE ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9) || PY_MAJOR_VERSION >= 4)
4546

47+
#define PyIU_USE_DICT_INTERNALS (PYIU_CPYTHON && (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 13)) // https://github.com/python/cpython/pull/108449 and https://github.com/python/cpython/pull/112115
48+
4649
#ifdef Py_IS_TYPE
4750
#define PyIU_USE_BUILTIN_IS_TYPE 1
4851
#else

0 commit comments

Comments
 (0)