Select Git revision
CHANGES.rst
-
Stefan Behnel authoredStefan Behnel authored
CHANGES.rst 126.15 KiB
Cython Changelog
3.0.0 alpha 6 (2020-0?-??)
Features added
- Special methods for binary operators now follow Python semantics.
Rather than e.g. a single
__add__
method for cdef classes, where "self" can be either the first or second argument, one can now define both__add__
and__radd__
as for standard Python classes . This behavior can be disabled with thec_api_binop_methods
directive to return to the previous semantics in Cython code. (Github issue #2056) - No/single argument functions now accept keyword arguments by default in order
to comply with Python semantics. The marginally faster calling conventions
METH_NOARGS
andMETH_O
that reject keyword arguments are still available with the directive@cython.always_allow_keywords(False)
. (Github issue #3090) - The
@returns()
decorator propagates exceptions by default for suitable C return types when no@exceptval()
is defined. (Github issue #3664) - A low-level inline function
total_seconds(timedelta)
was added tocpython.datetime
to bypass the Python method call. Note that this function is not guaranteed to give exactly the same results for very large time intervals. Patch by Brock Mendel. (Github issue #3616) - Type inference now understands that
a, *b = x
assigns a list tob
.
Bugs fixed
- The C++
typeid()
function was allowed in C mode. Patch by Celelibi. (Github issue #3637) - Includes all bug-fixes from the 0.29.20 release.
Other changes
- The
numpy
declarations were updated. Patch by Brock Mendel. (Github issue #3630) - The names of Cython's internal types (functions, generator, coroutine, etc.)
are now qualified with the module name of the internal Cython module that is
used for sharing them across Cython implemented modules, for example
_cython_3_0a5.coroutine
. This was done to avoid making them look like homeless builtins, to help with debugging, and in order to avoid a CPython warning according to https://bugs.python.org/issue20204
3.0.0 alpha 5 (2020-05-19)
Features added
-
.pxd
files can now be versioned by adding an extension like ".cython-30.pxd
" to prevent older Cython versions (than 3.0 in this case) from picking them up. (Github issue #3577) - Several macros/functions declared in the NumPy API are now usable without holding the GIL.
-
libc.math
was extended to include all C99 function declarations. Patch by Dean Scarff. (Github issue #3570)
Bugs fixed
- Several issues with arithmetic overflow handling were resolved, including undefined behaviour in C. Patch by Sam Sneddon. (Github issue #3588)
- The improved GIL handling in
nogil
functions introduced in 3.0a3 could fail to acquire the GIL in some cases on function exit. (Github issue #3590 etc.) - A reference leak when processing keyword arguments in Py2 was resolved, that appeared in 3.0a1. (Github issue #3578)
- The outdated getbuffer/releasebuffer implementations in the NumPy
declarations were removed so that buffers declared as
ndarray
now use the normal implementation in NumPy. - Includes all bug-fixes from the 0.29.18 release.
3.0.0 alpha 4 (2020-05-05)
Features added
- The
print
statement (not theprint()
function) is allowed innogil
code without an explicitwith gil
section. - The
assert
statement is allowed innogil
sections. Here, the GIL is only acquired if theAssertionError
is really raised, which means that the evaluation of the asserted condition only allows C expressions. - Cython generates C compiler branch hints for unlikely user defined if-clauses
in more cases, when they end up raising exceptions unconditionally. This now
includes exceptions being raised in
nogil
/with gil
sections. - Some internal memoryview functions were tuned to reduce object overhead.
Bugs fixed
- Exception position reporting could run into race conditions on threaded code. It now uses function-local variables again.
- Error handling early in the module init code could lead to a crash.
- Error handling in
cython.array
creation was improved to avoid calling C-API functions with an error held. - Complex buffer item types of structs of arrays could fail to validate. Patch by Leo and smutch. (Github issue #1407)
- When importing the old Cython
build_ext
integration with distutils, the additional command line arguments leaked into the regular command. Patch by Kamekameha. (Github issue #2209) - The improved GIL handling in
nogil
functions introduced in 3.0a3 could generate invalid C code. (Github issue #3558) -
PyEval_InitThreads()
is no longer used in Py3.7+ where it is a no-op. - Parallel builds of Cython itself (
setup.py build_ext -j N
) failed on Windows.
Other changes
- The C property feature has been rewritten and now requires C property methods
to be declared
inline
.
3.0.0 alpha 3 (2020-04-27)
Features added
-
nogil
functions now avoid acquiring the GIL on function exit if possible even if they containwith gil
blocks. (Github issue #3554) - Python private name mangling now falls back to unmangled names for non-Python globals, since double-underscore names are not uncommon in C. Unmangled Python names are also still found as a legacy fallback but produce a warning. Patch by David Woods. (Github issue #3548)
Bugs fixed
- Includes all bug-fixes from the 0.29.17 release.
3.0.0 alpha 2 (2020-04-23)
Features added
-
std::move()
is now used in C++ mode for internal temp variables to make them work without copying values. Patch by David Woods. (Github issues #3253, 1612) -
__class_getitem__
is supported for types on item access (PEP-560). Patch by msg555. (Github issue #2753) - The simplified Py3.6 customisation of class creation is implemented (PEP-487). (Github issue #2781)
- Conditional blocks in Python code that depend on
cython.compiled
are eliminated at an earlier stage, which gives more freedom in writing replacement Python code. Patch by David Woods. (Github issue #3507) -
numpy.import_array()
is automatically called ifnumpy
has been cimported and it has not been called in the module code. This is intended as a hidden fail-safe so user code should continue to callnumpy.import_array
. Patch by David Woods. (Github issue #3524) - The Cython AST code serialiser class
CodeWriter
inCython.CodeWriter
supports more syntax nodes. - The fastcall/vectorcall protocols are used for several internal Python calls. (Github issue #3540)
Bugs fixed
- With
language_level=3/3str
, Python classes without explicit base class are now new-style (type) classes also in Py2. Previously, they were created as old-style (non-type) classes. (Github issue #3530) - C++
typeid()
failed for fused types. Patch by David Woods. (Github issue #3203) -
__arg
argument names in methods were not mangled with the class name. Patch by David Woods. (Github issue #1382) - Creating an empty unicode slice with large bounds could crash. Patch by Sam Sneddon. (Github issue #3531)
- Decoding an empty bytes/char* slice with large bounds could crash. Patch by Sam Sneddon. (Github issue #3534)
- Temporary buffer indexing variables were not released and could show up in C compiler warnings, e.g. in generators. Patch by David Woods. (Github issues #3430, #3522)
- Several C compiler warnings were fixed.