Version: current master (frozenlist 1.8.1.dev0, commit after the free-threading changes)
Platform: Windows, CPython 3.13.7 — not platform-specific
Summary
Any FrozenList instance fails to pickle when the C extension is used:
import pickle
from frozenlist import FrozenList
fl = FrozenList([3, 1, 2])
fl.freeze()
pickle.dumps(fl)
TypeError: self._frozen cannot be converted to a Python object for pickling
The pure-Python implementation (FROZENLIST_NO_EXTENSIONS=1) round-trips fine on the same interpreter, so the two implementations have diverged.
Root cause
_frozenlist.pyx declares cdef atomic[bint] _frozen (added for free-threading support). Cython's auto-generated __reduce_cython__ cannot convert a libcpp.atomic.atomic[bint] member to a Python object, so pickling raises for every instance.
There is also no test coverage for pickling at all right now, which is why this went unnoticed.
Suggested fix
An explicit __reduce__ in the pyx class that serializes (items, frozen) through a small module-level constructor restores parity with the pure-Python implementation without giving up the atomic.
Version: current master (
frozenlist 1.8.1.dev0, commit after the free-threading changes)Platform: Windows, CPython 3.13.7 — not platform-specific
Summary
Any
FrozenListinstance fails to pickle when the C extension is used:The pure-Python implementation (
FROZENLIST_NO_EXTENSIONS=1) round-trips fine on the same interpreter, so the two implementations have diverged.Root cause
_frozenlist.pyxdeclarescdef atomic[bint] _frozen(added for free-threading support). Cython's auto-generated__reduce_cython__cannot convert alibcpp.atomic.atomic[bint]member to a Python object, so pickling raises for every instance.There is also no test coverage for pickling at all right now, which is why this went unnoticed.
Suggested fix
An explicit
__reduce__in the pyx class that serializes(items, frozen)through a small module-level constructor restores parity with the pure-Python implementation without giving up the atomic.