diff --git a/noxfile.py b/noxfile.py index 0a708de..0ec7240 100644 --- a/noxfile.py +++ b/noxfile.py @@ -72,7 +72,7 @@ def tests(session): stdout=summary, ) else: - session.run("pytest", *session.posargs, TESTS) + session.run("pytest", "--parallel-threads=10", *session.posargs, TESTS) @session() diff --git a/src/lib.rs b/src/lib.rs index 09583f8..c95c40a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1385,7 +1385,7 @@ impl QueuePy { } } -#[pymodule] +#[pymodule(gil_used = false)] #[pyo3(name = "rpds")] fn rpds_py(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; diff --git a/tests/requirements.in b/tests/requirements.in index 1c3a2db..8dc90bd 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,2 +1,3 @@ file:.#egg=rpds-py pytest +pytest-run-parallel diff --git a/tests/requirements.txt b/tests/requirements.txt index 325c3ee..0a7421a 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in +# uv pip compile --output-file tests/requirements.txt tests/requirements.in iniconfig==2.0.0 # via pytest packaging==24.1 @@ -7,6 +7,10 @@ packaging==24.1 pluggy==1.5.0 # via pytest pytest==8.3.3 + # via + # -r tests/requirements.in + # pytest-run-parallel +pytest-run-parallel==0.2.0 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9f2d763..3dec414 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -30,11 +30,22 @@ from collections import abc from operator import methodcaller import pickle +import sysconfig import pytest from rpds import HashTrieMap +# see https://github.com/python/cpython/issues/127065, +# remove this when the CPython bug is fixed in a released version +if bool(sysconfig.get_config_var("Py_GIL_DISABLED")): + + def methodcaller(name, /, *args, **kwargs): + def caller(obj): + return getattr(obj, name)(*args, **kwargs) + + return caller + def test_instance_of_hashable(): assert isinstance(HashTrieMap(), abc.Hashable)