Skip to content

Commit

Permalink
preparations for the next release
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Feb 2, 2025
1 parent 90ef5bc commit 30f4200
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
37 changes: 20 additions & 17 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ case, both modules must use the same nanobind ABI version, or they will be
isolated from each other. Releases that don't explicitly mention an ABI version
below inherit that of the preceding release.

Version TBD (not yet released)
------------------------------
Version 2.5.0 (Feb 2, 2025)
---------------------------

- Added :cpp:class:`nb::def_visitor\<..\> <def_visitor>`, which can be used to
define your own binding logic that operates on a :cpp:class:`nb::class_\<..\>
Expand Down Expand Up @@ -58,21 +58,6 @@ Version TBD (not yet released)
instances were still alive at interpreter shutdown time. (commit `fb8157
<https://github.com/wjakob/nanobind/commit/fb815762fdb8476cfd293e3717ca41c8bb890437>`__).

- Fixed a race condition in free-threaded extensions that could occur when
:cpp:func:`nb::make_iterator <make_iterator>` was concurrently used by
multiple threads (PR `#832 <https://github.com/wjakob/nanobind/pull/832>`__).

- Fixed a race condition in free-threaded extensions that could occur when
multiple threads access the Python object associated with the same C++
instance, which does not exist yet and therefore must be created. (issue
`#867 <https://github.com/wjakob/nanobind/issues/867>`__, PR `#887
<https://github.com/wjakob/nanobind/pull/887>`__).

- Removed double-checked locking patterns in accesses to internal data
structures to ensure correct free-threaded behavior on architectures with
weak memory ordering such as ARM (PR `#819
<https://github.com/wjakob/nanobind/pull/819>`__).

- The floating-point type caster now only performs value-changing narrowing
conversions during the implicit conversion phase. They can be entirely
avoided by passing the :cpp:func:`.noconvert() <arg::noconvert>` argument
Expand All @@ -91,6 +76,24 @@ Version TBD (not yet released)
<https://github.com/wjakob/nanobind/pull/847>`__, commit `b95eb7
<https://github.com/wjakob/nanobind/commit/b95eb755b5a651a40562002be9ca8a4c6bf0acb9>`__).

Fixes for free-threaded builds
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fixed a race condition in free-threaded extensions that could occur when
:cpp:func:`nb::make_iterator <make_iterator>` was concurrently used by
multiple threads (PR `#832 <https://github.com/wjakob/nanobind/pull/832>`__).

- Fixed a race condition in free-threaded extensions that could occur when
multiple threads access the Python object associated with the same C++
instance, which does not exist yet and therefore must be created. (issue
`#867 <https://github.com/wjakob/nanobind/issues/867>`__, PR `#887
<https://github.com/wjakob/nanobind/pull/887>`__).

- Removed double-checked locking patterns in accesses to internal data
structures to ensure correct free-threaded behavior on architectures with
weak memory ordering such as ARM (PR `#819
<https://github.com/wjakob/nanobind/pull/819>`__).

Version 2.4.0 (Dec 6, 2024)
---------------------------

Expand Down
10 changes: 6 additions & 4 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,10 @@ void print(PyObject *value, PyObject *end, PyObject *file) {

NB_CORE bool load_cmplx(PyObject *ob, uint8_t flags,
std::complex<double> *out) noexcept {
bool is_complex = PyComplex_CheckExact(ob);
bool is_complex = PyComplex_CheckExact(ob),
convert = (flags & (uint8_t) cast_flags::convert);
#if !defined(Py_LIMITED_API)
if (is_complex || (flags & (uint8_t) cast_flags::convert)) {
if (is_complex || convert) {
Py_complex result = PyComplex_AsCComplex(ob);
if (result.real != -1.0 || !PyErr_Occurred()) {
*out = std::complex<double>(result.real, result.imag);
Expand All @@ -917,7 +918,7 @@ NB_CORE bool load_cmplx(PyObject *ob, uint8_t flags,
#if Py_LIMITED_API < 0x030D0000
// Before version 3.13, __complex__() was not called by the Stable ABI
// functions PyComplex_{Real,Imag}AsDouble(), so we do so ourselves.
if (!is_complex && (flags & (uint8_t) cast_flags::convert)
if (!is_complex && convert
&& !PyType_IsSubtype(Py_TYPE(ob), &PyComplex_Type)
&& PyObject_HasAttrString(ob, "__complex__")) {
PyObject* tmp = PyObject_CallFunctionObjArgs(
Expand All @@ -935,7 +936,7 @@ NB_CORE bool load_cmplx(PyObject *ob, uint8_t flags,
return false;
}
#endif
if (is_complex || (flags & (uint8_t) cast_flags::convert)) {
if (is_complex || convert) {
double re = PyComplex_RealAsDouble(ob);
double im = PyComplex_ImagAsDouble(ob);
if ((re != -1.0 && im != -1.0) || !PyErr_Occurred()) {
Expand All @@ -946,6 +947,7 @@ NB_CORE bool load_cmplx(PyObject *ob, uint8_t flags,
}
}
#endif

return false;
}

Expand Down

0 comments on commit 30f4200

Please sign in to comment.