Skip to content

Releases: cython/cython

3.1.0a1

08 Nov 19:25
Compare
Choose a tag to compare
3.1.0a1 Pre-release
Pre-release

3.1.0 alpha 1 (2024-11-08)

Features added

  • Support for freethreading builds of CPython 3.13 was added.
    It comes with a new directive freethreading_compatible=True to mark modules as
    free-threading compatible (Py_mod_gil).
    https://github.com/cython/cython/issues?q=label%3A"nogil+CPython"
    Patches by Lysandros Nikolaou and Nathan Goldbaum. (Github issue :issue:6162)

  • Support for monitoring Cython modules via sys.monitoring in CPython 3.13+ was added.
    For coverage reporting, this needs to be disabled with -DCYTHON_USE_SYS_MONITORING=0
    as long as coverage.py does not support sys.monitoring for coverage plugins.
    (Github issue :issue:6144)

  • Many issues with the Limited C-API were resolved.
    It is now sufficient to define the macro Py_LIMITED_API to activate the support.
    https://github.com/cython/cython/issues?q=label%3A%22limited+api%22

  • Support for GraalPython was improved (but is still incomplete).

  • Several issues with the gdb support were resolved.
    Patches by Kent Slaney. (Github issues :issue:5955, :issue:5948)

  • typing.Union[SomeType, None] and SomeType | None are now understood and mean
    the same as typing.Optional[SomeType], allowing None in type checks.
    (Github issue :issue:6254)

  • cython.const[] and cython.volatile[] are now available as type modifiers in Python code.
    (Github issue :issue:5728)

  • cython.pointer[SomeCType] can now be used to define pointer types in Python type annotations.
    (Github issue :issue:5071)

  • Several improvements were made to reduce the size of the resulting extension modules.
    (Github issue :issue:4425)

  • Function calls now use the PEP-590 Vectorcall protocol, even when passing keyword arguments.
    (Github issues :issue:5804)

  • Coroutines now use the am_send slot function instead of going through a Python .send() call.
    This has been backported for Python 3.7 - 3.9.
    (Github issues :issue:4585)

  • __set_name__ is called when assigning to class attributes.
    (Github issue :issue:6179)

  • Most builtin methods now provide their return type for type inference.
    (Github issues :issue:4829, :issue:5865, :issue:6412)

  • Method calls on builtin literal values are evaluated at compile time, if applicable.
    (Github issue :issue:6383)

  • The Python int type now maps directly to PyLong and is inferred accordingly.
    (Github issue :issue:4237)

  • Integer operations on known int types are faster.
    (Github issue :issue:5785)

  • f-strings are faster in some cases.
    (Github issues :issue:5866, :issue:6342, :issue:6383)

  • divmod() is faster on C integers.
    Patch by Tong He. (Github issue :issue:6073)

  • dict.pop() is faster in some cases.
    (Github issue :issue:5911)

  • .isprintable() is optimised for Unicode characters.
    (Github issue :issue:3277)

  • x in () and similar tests against empty constant sequences (e.g. in generated code)
    are now discarded if they have no side-effects.
    (Github issue :issue:6288)

  • Constant (non-GC) Python objects are no longer traversed with Py_VISIT() during GC runs.
    (Github issue :issue:6277)

  • C++ classes implemented in Cython can now use method overloading.
    Patch by samaingw. (Github issue :issue:3235)

  • Assigning a Python container to a C++ vector now makes use of __length_hint__
    to avoid reallocations.
    Patch by Denis Lukianov. (Github issue :issue:6077)

  • The C++11 emplace* methods were added to libcpp.deque.
    Patch by Somin An. (Github issue :issue:6159)

  • cpython.time was updated and extended for Python 3.13.
    (Github issue :issue:6187)

  • Dataclasses support the match_args option.
    (Github issue :issue:5381)

  • Threading in parallel sections can now be disabled with a new use_threads_if condition.
    (Github issue :issue:5919)

  • New options warn.deprecated.DEF and warn.deprecated.IF can silence the deprecation warnings.
    Patch by Eric Larson. (Github issue :issue:6243)

  • cygdb shows more helpful output for some objects.
    Patch by Kent Slaney. (Github issue :issue:5958)

  • Bazel build support for improved.
    Patch by mering. (Github issue :issue:6452)

  • The parser was updated for Unicode 15.1 (as provided by CPython 3.13b4).

Bugs fixed

  • C functions used different start lines and columns for error reporting and tracing
    than Python functions. They now use the line and column of their first decorator
    or (if none) their definition line, as in Python.
    (Github issue :issue:6366)

  • Dataclasses did not handle default fields without init value correctly.
    (Github issue :issue:5858)

  • Implementing a special method based on another could lead to infinite recursion.
    (Github issue :issue:5863)

  • The __class__ cell variable in methods was not always working as in Python.
    Initial patch by Tom Keefe. (Github issue :issue:2912)

  • Lambda functions had no code objects. Their signature can now be introspected.
    (Github issue :issue:2983)

  • Subtyping complex as extension type could fail.
    (Github issue :issue:6346)

  • hasattr() now propagates exceptions that occur during lookup.
    (Github issue :issue:6269)

  • The base type of extension heap types is now traversed during GC runs in Py3.9+.
    (Github issue :issue:4193)

  • The Python & operator could touch invalid memory with certain 0 values in Python <= 3.10.
    Patch by Michael J. Sullivan. (Github issue :issue:4193)

  • Exception values were not always recognised as equal at compile time.
    (Github issue :issue:5709)

  • Running Cython in different Python versions could generate slightly different C code
    due to differences in the builtins.
    (Github issue :issue:5591)

  • The common_include_dir feature used different file paths in the C code on Windows and Posix.
    It now uses forward slashes as directory separator consistently.
    (Github issue :issue:6355)

  • File paths in the C code are now relative to the build directory.
    Patch by Oscar Benjamin. (Github issue :issue:6341)

  • depfiles now use relative paths whenever possible.
    Patch by Loïc Estève. (Github issue :issue:6345)

  • The -a option in the IPython magic no longer copies the complete HTML document
    into the notebook but only a more reasonable content snippet.
    Patch by Min RK. (Github issue :issue:5760)

  • Uselessly referring to C enums (not enum values) as Python objects is now rejected.
    Patch by Vyas Ramasubramani. (Github issue :issue:5638)

  • Cython no longer acquires the GIL during in-place assignments to C attributes in nogil sections.
    Patch by Mads Ynddal. (Github issue :issue:6407)

  • Several C++ warnings about char* casts were resolved.
    (Github issues :issue:5515, :issue:5847)

  • C++ undefined behaviour was fixed in an error handling case.
    (Github issue :issue:5278)

  • Dict assignments to struct members with reserved C/C++ names could generate invalid C code.

  • The PEP-479 implementation could raise a visible RuntimeError without
    a trace of the original StopIteration.
    (Github issue :issue:5953)

  • A crash was fixed when assigning a zero-length slice to a memoryview.
    Patch by Michael Man. (Github issue :issue:6227)

  • Conditionally assigning to variables with the walrus operator could crash.
    (Github issue :issue:6094)

  • Unterminated string literals could lock up the build in an infinite loop.
    (Github issue :issue:5977)

  • Exporting C functions uses better platform compatible code.
    (Github issue :issue:4683)

  • The shebang in libpython.py was incorrect.
    Patch by Luke Hamburg. (Github issue :issue:6439)

  • Cython now uses SHA-256 instead of SHA-1 for caching etc. as the latter may not be
    available on all Python installations.
    (Github issue :issue:6354)

Other changes

  • Support for Python 2.7 - 3.7 was removed, along with large chunks of legacy code.
    (Github issue :issue:2800)

  • The pxd files cpython.int, cpython.cobject, cpython.oldbuffer and cpython.string
    were removed as they refer to C-API declarations that are only in Python 2.x.
    (Github issue :issue:5870)

  • The generated C code now requires a C99 compatible C compiler.

  • language_level=3 is now the default.
    language_level=3str has become a legacy alias.
    (Github issue :issue:5827)

  • The Py2 types unicode and basestring are now deprecated and have become aliases
    of the str type.
    (Github issue :issue:6374)

  • Docstrings now strip their leading whitespace according to PEP-257.
    Patch by Lawrence Mitchell. (Github issue :issue:6241)

  • Type checkers should have it easier to find and validate Cython types in .py files.
    (Github issue :issue:4327)

  • The previously shipped NumPy C-API declarations (cimport numpy) were removed.
    NumPy has been providing version specific declarations for several versions now.
    (Github issue :issue:5842)

  • Usages of the outdated WITH_THREAD macro guard were removed.
    (Github issue :issue:5812)

  • The options for showing the C code line in Python exception stack traces were cleaned up.
    Previously, disabling the option with the CYTHON_CLINE_IN_TRACEBACK macro did not
    reduce the code overhead of the feature, and the c_line_in_traceback compile 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 macro ``CYTHON_CLINE_IN_TRACEBACK...

Read more

3.0.11-1

05 Aug 13:26
Compare
Choose a tag to compare
3.0.11 (2024-08-05)

===================

Features added
--------------

* The C++11 ``emplace*`` methods were added to ``libcpp.deque``.
  Patch by Somin An.  (Github issue :issue:`6159`)

Bugs fixed
----------

* The exception check value of functions declared in pxd files was not always applied in 3.0.10.
  (Github issue :issue:`6122`)

* A crash on exception deallocations was fixed.
  (Github issue :issue:`6022`)

* A crash was fixed when assigning a zero-length slice to a memoryview.
  Patch by Michael Man.  (Github issue :issue:`6227`)

* ``libcpp.optional.value()`` could crash if it raised a C++ exception.
  Patch by Alexander Condello.  (Github issue :issue:`6190`)

* The return type of ``str()`` was mishandled, leading to crashes with ``language_level=3``.
  (Github issue :issue:`6166`)

* ``bytes.startswith/endswith()`` failed for non-bytes substrings (e.g. ``bytearray``).
  (Github issue :issue:`6168`)

* Fused ctuples crashed Cython.
  (Github issue :issue:`6068`)

* A compiler crash was fixed when using extension types in fused types.
  (Github issue :issue:`6204`)

* The module cleanup code was incorrect for globally defined memory view slices.
  (Github issue :issue:`6276`)

* Some adaptations were made to enable compilation in Python 3.13.
  (Github issues :issue:`5997`, :issue:`6182`, :issue:`6251`)

3.0.10

30 Mar 17:50
Compare
Choose a tag to compare
3.0.10 (2024-03-30)

===================

Bugs fixed
----------

* Cython generated incorrect self-casts when directly calling final methods of subtypes.
  Patch by Lisandro Dalcin.  (Github issue :issue:`2747`)

* Internal C names generated from C function signatures could become too long for MSVC.
  (Github issue :issue:`6052`)

* The ``noexcept`` warnings could be misleading in some cases.
  Patch by Gonzalo TornarΓ­a.  (Github issue :issue:`6087`)

* The ``@cython.ufunc`` implementation could generate incomplete C code.
  (Github issue :issue:`6064`)

* The ``libcpp.complex`` declarations could result in incorrect C++ code.
  Patch by Raffi Enficiaud.  (Github issue :issue:`6037`)

* Several tests were adapted to work with both NumPy 1.x and 2.0.
  Patch by Matti Picus.  (Github issues :issue:`6076`, :issue:`6100`)

* C compiler warnings when the freelist implementation is disabled (e.g. on PyPy) were fixed.
  It can now be disabled explicitly with the C macro guard ``CYTHON_USE_FREELISTS=0``.
  (Github issue :issue:`6099`)

* Some C macro guards for feature flags were missing from the NOGIL Python configuration.

* Some recently added builtins were unconditionally looked up at module import time
  (if used by user code) that weren't available on all Python versions and could thus
  fail the import.

* A performance hint regarding exported pxd declarations was improved.
  (Github issue :issue:`6001`)

3.0.9

05 Mar 13:36
Compare
Choose a tag to compare
3.0.9

3.0.8

10 Jan 08:16
Compare
Choose a tag to compare
3.0.8

3.0.7

19 Dec 10:08
Compare
Choose a tag to compare
3.0.7

0.29.37.1

19 Dec 09:26
Compare
Choose a tag to compare

Binary-only release for Py3.12.

0.29.37

19 Dec 08:58
Compare
Choose a tag to compare
0.29.37

3.0.6

26 Nov 13:32
Compare
Choose a tag to compare
3.0.6

3.0.5

30 Oct 20:45
Compare
Choose a tag to compare
3.0.5