Skip to content

Commit

Permalink
miscellaneous cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Feb 18, 2024
1 parent 7df32f1 commit 8efd965
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ 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 1.9.0 (TBA)
-------------------
Version 1.9.0 (Feb 18, 2024)
----------------------------

* Nanobind instances can now be :ref:`made weak-referenceable <weak_refs>` by
specifying the :cpp:class:`nb::weak_referenceable <weak_referenceable>` tag
in the :cpp:class:`nb::class_\<..\> <class_>` constructor. (PR `#335
<https://github.com/wjakob/nanobind/pull/335>`__, commit `fc7709
<https://github.com/wjakob/nanobind/commit/fc770930468313e5a69364cfd1bbdab9bc0ab208>`__).

* Added a :py:class:`nb:bool_ <bool_>` wrapper type. (PR `#382
* Added a :cpp:class:`nb::bool_ <bool_>` wrapper type. (PR `#382
<https://github.com/wjakob/nanobind/pull/382>`__, commit `90dfba
<https://github.com/wjakob/nanobind/commit/90dfbaf4c8c410d819cb9be44a3455898c8c2638>`__).

Expand All @@ -41,7 +41,7 @@ Version 1.9.0 (TBA)
``noexcept``. (PR `#386 <https://github.com/wjakob/nanobind/pull/386>`__).

* Fixed memory corruption in a PyPy-specific codepath in
:cpp:func:`nb::module_::def_submodule <module_::def_submodule>` (commit
:cpp:func:`nb::module_::def_submodule() <module_::def_submodule>` (commit
`21eaff
<https://github.com/wjakob/nanobind/commit/21eaffc263c13a5373546d8957e4152e65b1e8ac>`__).

Expand All @@ -58,7 +58,7 @@ Version 1.9.0 (TBA)
`#393 <https://github.com/wjakob/nanobind/pull/393>`__, commit `b3b6f4
<https://github.com/wjakob/nanobind/commit/b3b6f44e55948986e02cdbf67e04d9cdd11c4aa4>`__).

* Don't pass compiler flags if the may be unsupported by the used compiler.
* Don't pass compiler flags if they may be unsupported by the used compiler.
This gets NVCC to work out of the box (that said, this change does not
elevate NVCC to being an *officially* supported compiler). (issue `#383
<https://github.com/wjakob/nanobind/pull/383>`__, commit `a307ea
Expand Down Expand Up @@ -211,9 +211,9 @@ New features
<ndarray-nonstandard>` for details. (commit `49eab2
<https://github.com/wjakob/nanobind/commit/49eab2845530f84a1f029c5c1c5541ab3c1f9adc>`__).

3. Shape constraints like :py:class:`nb::shape\<nb::any, nb::any, nb::any\>
3. Shape constraints like :cpp:class:`nb::shape\<nb::any, nb::any, nb::any\>
<shape>` are tedious to write. Now, there is a shorter form:
:py:class:`nb::ndim\<3\> <ndim>`. (commit `1350a5
:cpp:class:`nb::ndim\<3\> <ndim>`. (commit `1350a5
<https://github.com/wjakob/nanobind/commit/1350a5e15b28e80ffc2130a779f3b8c559ddb620>`__).

4. Added an explicit constructor that can be used to add or remove ndarray
Expand Down Expand Up @@ -479,7 +479,7 @@ Miscellaneous fixes and improvements

* Enum equality comparisons (``==`` and ``!=``) now can only be true
if both operands have the same enum type, or if one is an enum and
the other is an :py:class:`int`. This resolves some confusing
the other is an ``int``. This resolves some confusing
results and ensures that enumerators of different types have a
distinct identity, which is important if they're being put into
the same set or used as keys in the same dictionary. All of the
Expand Down
6 changes: 3 additions & 3 deletions docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ Weak references
By default, nanobind instances cannot be referenced via Python's ``weakref``
class, and attempting to do so will raise an exception.

To support this, add the :class:`nb::is_weak_referenceable
<is_weak_referenceable>` tag to the :class:`nb::class_ <class_>` constructor.
To support this, add the :class:`nb::weak_referenceable
<weak_referenceable>` tag to the :class:`nb::class_ <class_>` constructor.
Note that this will increase the size of every instance by ``sizeof(void*)``
due to the need to store a weak reference list.

.. code-block:: cpp
nb::class_<Pet>(m, "Pet", nb::is_weak_referenceable());
nb::class_<Pet>(m, "Pet", nb::weak_referenceable());
.. _inheriting_in_python:

Expand Down
4 changes: 2 additions & 2 deletions src/nb_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void inst_dealloc(PyObject *self) {
}
}

if (t->flags & (uint32_t)type_flags::is_weak_referenceable &&
if (t->flags & (uint32_t) type_flags::is_weak_referenceable &&
nb_weaklist_ptr(self) != nullptr) {
#if defined(PYPY_VERSION)
PyObject **weaklist = nb_weaklist_ptr(self);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ PyObject *nb_type_new(const type_init_data *t) noexcept {
}

if (is_weak_referenceable) {
to->flags |= (uint32_t)type_flags::is_weak_referenceable;
to->flags |= (uint32_t) type_flags::is_weak_referenceable;
#if defined(Py_LIMITED_API)
to->weaklistoffset = weaklistoffset;
#endif
Expand Down

0 comments on commit 8efd965

Please # to comment.