Skip to content

Commit 18cdbbe

Browse files
committed
Test limited API
After watching https://ep2024.europython.eu/session/cython-and-the-limited-api/, I wanted to test how well switching to the stable ABI would work. It would be great to be able to build a single wheel for each platform and not have to update when a new Python version gets released. There are two issues. The first is that using the limited API makes dnaio slower. Reading FASTQ files takes 50% more time. I did not benchmark anything else. It was actually about 10 time slower when I used the limited API for Python 3.7. (This PR uses what is available in Python 3.12.) Maybe this will get better in newer versions. The second issue is that still some non-ABI3 symbols are being used in our code, in particular PyUnicode_New. abi3audit (https://github.com/pypa/abi3audit) outputs this: ``` $ abi3audit -v --assume-minimum-abi3 3.12 src/dnaio/_core.abi3.so [09:47:43] 👎 : _core.abi3.so has non-ABI3 symbols ┏━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Symbol ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ PyUnicode_New │ │ Py_CompileStringExFlags │ │ _Py_FatalErrorFunc │ └─────────────────────────┘ 💁 _core.abi3.so: 1 extensions scanned; 0 ABI version mismatches and 3 ABI violations found ``` This PR is just meant to document the experiment, so I’ll close it right away.
1 parent 213563e commit 18cdbbe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

setup.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
else:
1111
DEFINE_MACROS = []
1212

13+
DEFINE_MACROS += [
14+
("CYTHON_LIMITED_API", 1),
15+
("Py_Limited_API", 0x030C0000),
16+
]
17+
1318
setup(
1419
ext_modules=[
1520
Extension(
16-
"dnaio._core", sources=["src/dnaio/_core.pyx"], define_macros=DEFINE_MACROS
21+
"dnaio._core",
22+
sources=["src/dnaio/_core.pyx"],
23+
define_macros=DEFINE_MACROS,
24+
py_limited_api=True,
1725
),
1826
],
1927
)

0 commit comments

Comments
 (0)