Opened 9 months ago
Closed 9 months ago
#21551 closed enhancement (fixed)
cython-3.1.0 (Python module)
| Reported by: | Bruce Dubbs | Owned by: | Bruce Dubbs |
|---|---|---|---|
| Priority: | normal | Milestone: | 12.4 |
| Component: | BOOK | Version: | git |
| Severity: | normal | Keywords: | |
| Cc: |
Description
New minor version.
Change History (3)
comment:1 by , 9 months ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 9 months ago
comment:3 by , 9 months ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Fixed at commits
cd6aaac888 Update to nss-3.111. 63ab222e83 Update to SDL2-2.32.6. 8c86698398 Update to cython-3.1.0 (Python module).
Note:
See TracTickets
for help on using tickets.

3.1.0 (2025-05-08)
Other changes
3.1.0 rc 2 (2025-05-07)
Features added
std::stop_tokenwere added aslibcpp.stop_tokento provide additional low-level synchronisation primitives also in the light of free-threading Python.cythonize()in asetuptoolsbuild if a correspondingExtensionhas been configured. This avoids an additional step outside of thesetup.pyorpip wheelrun.Bugs fixed
BaseException,ExceptionorOSError, which almost always intend to reference subtypes.call_once()function argument inlibc.threads(new in 3.1) was changed to require anogildeclaration, as semantically implied. Code that used it with a callback function expecting to hold the GIL must change the callback code to usewith gil.str += "") could trigger an infinite loop in Cython.new()on ctypedefs.cpp_localsin nogil sections could crash.const structdeclarations could lead to invalid assignments toconsttemp variables.Features added
cython.pymutexprovides a fast mutex by wrapping the newPyMutexfeature of recent CPython versions (including free-threading) and falls back toPyThreadlocks in older Pythons.subinterpreters_compatible=shared_gil/own_gilwas added to allow modules to declare support for subinterpreters.divmod()is also optimised for C floating point types and can be called on C number types without holding the GIL.embedsignaturenow works for special methods (if they have a docstring).Bugs fixed
divmod()calls could produce incorrect results in beta-1 due to incorrect C type usage.UnboundLocalErrorcould fail for non-ascii variable names.PyByteArray_Resize()incpython.bytearrayfailed to propagate exceptions.cythonize_one()accidentally changed in 3.1.0b1.Other changes
cpdef enumsno longer copy their item names into the global module namespace. This was considered unhelpful for named enums which already live in their own class namespace. In cases where the old behaviour was desired, users can add the following backwards compatible command after their enum class definition:globals().update(TheUserEnumClass.members). Anonymous enums still produce global item names, as before.Features added
cdef const …variables are supported.cython.critical_sectionwas added wrapping Python's critical section C-API feature.prangeloop targets is now inferred.divmod()on any C integer types is efficient.PyObject_VectorcallMethod()where possible.exceptclause if it knows that they are unused.cythoncommand has a new option--cacheto cache generated files.cythonizecommand has a new option--timeitto benchmark Cython code snippets.cygdbcommand was improved based onargparse.PyWeakref_GetRefdeclaration was added tocpython.weakrefand backported.std::spandeclarations were added tolibcpp.std::string_viewdeclarations were added tolibcpp.libcandlibcppwere added.Demos/benchmarks/directory include a new benchmark runner that can run selected benchmarks against different Cython git revisions.Bugs fixed
for-inloops could generate invalid code for C++ containers.PyDict_GetItemRef()andPyList_GetItemRef()were not always used correctly.binding=False.sorted()could crash in 3.1.0a1.complex/complexwas resolved.cpp_localsdirective was resolved.@staticmethodin a pxd file and overriding it in a subclass could trigger incorrect "declared but not defined" errors.cygdbcould fail with anIndexError.gdbcompatibility ofcygdbwas improved.common_utility_include_diroption in parallel builds on Windows could fail.Other changes
numpy.mathcimport module has been deprecated. Usages should be replaced bylibc.math.3.1.0 alpha 1 (2024-11-08)
Features added
freethreading_compatible=Trueto mark modules as free-threading compatible (Py_mod_gil).sys.monitoringin CPython 3.13+ was added. For coverage reporting, this needs to be disabled with-DCYTHON_USE_SYS_MONITORING=0as long ascoverage.pydoes not supportsys.monitoringfor coverage plugins.Py_LIMITED_APIto activate the support.typing.Union[SomeType, None]andSomeType | Noneare now understood and mean the same astyping.Optional[SomeType], allowingNonein type checks.cython.const[]andcython.volatile[]are now available as type modifiers in Python code.cython.pointer[SomeCType]can now be used to define pointer types in Python type annotations.am_sendslot function instead of going through a Python.send()call.set_nameis called when assigning to class attributes.inttype now maps directly toPyLongand is inferred accordingly.inttypes are faster.divmod()is faster on Cint.dict.pop()is faster in some cases..isprintable()is optimised for Unicode characters.x in ()and similar tests against empty constant sequences (e.g. in generated code) are now discarded if they have no side-effects.Py_VISIT()during GC runs.length_hintto avoid reallocations.emplace*methods were added tolibcpp.deque.cpython.timewas updated and extended for Python 3.13.match_argsoption.use_threads_ifcondition.warn.deprecated.DEFandwarn.deprecated.IFcan silence the deprecation warnings.cygdbshows more helpful output for some objects.Bugs fixed
classcell variable in methods was not always working as in Python.complexas extension type could fail.hasattr()now propagates exceptions that occur during lookup.&operator could touch invalid memory with certain0values in Python <= 3.10.common_include_dirfeature used different file paths in the C code on Windows and Posix. It now uses forward slashes as directory separator consistently.-aoption in the IPython magic no longer copies the complete HTML document into the notebook but only a more reasonable content snippet.char*casts were resolved.RuntimeErrorwithout a trace of the originalStopIteration.libpython.pywas incorrect.SHA-256instead ofSHA-1for caching etc. as the latter may not be available on all Python installations.Other changes
cpython.int,cpython.cobject,cpython.oldbufferandcpython.stringwere removed as they refer to C-API declarations that are only in Python 2.x.language_level=3is now the default.language_level=3strhas become a legacy alias.unicodeandbasestringare now deprecated and have become aliases of thestrtype.cimport numpy) were removed. NumPy has been providing version specific declarations for several versions now.WITH_THREADmacro guard were removed.CYTHON_CLINE_IN_TRACEBACKmacro did not reduce the code overhead of the feature, and thec_line_in_tracebackcompile option was partly redundant with the C macro switches and lead to warnings about unused code. Since this is considered mostly a debug feature, the new default is that it is _disabled_ to avoid code and runtime overhead. It can be enabled by setting the C macro to 1, and a new macroCYTHON_CLINE_IN_TRACEBACK_RUNTIMEwas added that controls the runtime configurable setting if the feature is enabled, which was previously only available through the compile option. The compile option is now deprecated (but still available), and users should migrate to using the two C macros only.