Nanobind

Latest version: v2.5.0

Safety actively analyzes 706267 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 7

1.3.1

----------------------------

* CMake build system improvements for stable ABI wheel generation.
(PR `222 <https://github.com/wjakob/nanobind/pull/222>`__).

1.3.0

----------------------------

This is a big release. The sections below cover added features, efficiency
improvements, and miscellaneous fixes and improvements.

New features
^^^^^^^^^^^^
* nanobind now supports binding types that inherit from
``std::enable_shared_from_this<T>``. See the :ref:`advanced section
on object ownership <enable_shared_from_this>` for more details.
(PR `212 <https://github.com/wjakob/nanobind/pull/212>`__).
* Added a type caster between Python ``datetime``/``timedelta`` objects and
C++ ``std::chrono::duration``/``std::chrono::time_point``, ported
from pybind11. (PR `175 <https://github.com/wjakob/nanobind/pull/175>`__).
* The :cpp:class:`nb::ndarray\<..\> <ndarray>` class can now use the buffer
protocol to receive and return arrays representing read-only memory. (PR
`217 <https://github.com/wjakob/nanobind/pull/217>`__).
* Added :cpp:func:`nb::python_error::discard_as_unraisable()
<python_error::discard_as_unraisable>` as a wrapper around
``PyErr_WriteUnraisable()``. (PR `175
<https://github.com/wjakob/nanobind/pull/175>`__).

Efficiency improvements:
^^^^^^^^^^^^^^^^^^^^^^^^

* Reduced the per-instance overhead of nanobind by 1 pointer and simplified the
internal hash table types to crunch ``libnanobind``. (commit `de018d
<https://github.com/wjakob/nanobind/commit/de018db2d17905564703f1ade4aa201a22f8551f>`__).
* Supplemental type data specified via :cpp:class:`nb::supplement\<T\>()
<supplement>` is now stored directly within the type object instead of being
referenced through an indirection. (commit `d82ca9
<https://github.com/wjakob/nanobind/commit/d82ca9c14191e74dd35dd5bf15fc90f5230319fb>`__).
* Reduced the number of exception-related exports to further crunch
``libnanobind``. (commit `763962
<https://github.com/wjakob/nanobind/commit/763962b8ce76414148089ef6a68cff97d7cc66ce>`__).
* Reduced the size of nanobind type objects by 5 pointers. (PR `194
<https://github.com/wjakob/nanobind/pull/194>`__, `#195
<https://github.com/wjakob/nanobind/pull/195>`__, and commit `d82ca9
<https://github.com/wjakob/nanobind/commit/d82ca9c14191e74dd35dd5bf15fc90f5230319fb>`__).
* Internal nanobind types (``nb_type``, ``nb_static_property``, ``nb_ndarray``)
are now constructed on demand. This reduces the size of the ``libnanobind``
component in static (``NB_STATIC``) builds when those features are not used.
(commits `95e45a
<https://github.com/wjakob/nanobind/commit/95e45a4027dcbce935091533f7d41bf59e3e5fe1>`__,
`375083
<https://github.com/wjakob/nanobind/commit/37508386a1f8c346d17a0353c8152940aacde9c2>`__,
and `e033c8
<https://github.com/wjakob/nanobind/commit/e033c8fab4a14cbb9c5b0e08b1bdf49af2a9cb22>`__).
* Added a small function cache to improve code generation in limited API
builds. (commit `f0f4aa
<https://github.com/wjakob/nanobind/commit/f0f42a564995ba3bd573282674d1a6d636a048c8>`__).
* Refined compiler and linker flags across platforms to ensure compact binaries
especially in ``NB_STATIC`` builds. (commit `5ead9f
<https://github.com/wjakob/nanobind/commit/5ead9ff348a2ef0df8231e6480607a5b0623a16b>`__)
* nanobind enums now take advantage of :ref:`supplemental data <supplement>`
to improve the speed of object and name lookups. Note that this prevents
use of ``nb::supplement<T>()`` with enums for other purposes.
(PR `195 <https://github.com/wjakob/nanobind/pull/195>`__).

Miscellaneous fixes and improvements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Use the new `PEP-697 <https://peps.python.org/pep-0697/>`__ interface to
access data in type objects when compiling stable ABI3 wheels. This improves
forward compatibility (the Python team may at some point significantly
refactor the layout and internals of type objects). (PR `211
<https://github.com/wjakob/nanobind/pull/211>`__):
* Added introspection attributes ``__self__`` and ``__func__`` to nanobind
bound methods, to make them more like regular Python bound methods.
Fixed a bug where ``some_obj.method.__call__()`` would behave differently
than ``some_obj.method()``.
(PR `216 <https://github.com/wjakob/nanobind/pull/216>`__).
* Updated the implementation of :cpp:class:`nb::enum_ <enum_>` so it does
not take advantage of any private nanobind type details. As a side effect,
the construct ``nb::class_<T>(..., nb::is_enum(...))`` is no longer permitted;
use ``nb::enum_<T>(...)`` instead.
(PR `195 <https://github.com/wjakob/nanobind/pull/195>`__).
* Added the :cpp:class:`nb::type_slots_callback` class binding annotation,
similar to :cpp:class:`nb::type_slots` but allowing more dynamic choices.
(PR `195 <https://github.com/wjakob/nanobind/pull/195>`__).
* nanobind type objects now treat attributes specially whose names
begin with `. These attributes can be set once, but not
rebound or deleted. This safeguard allows a borrowed reference to
the attribute value to be safely stashed in the type supplement,
allowing arbitrary Python data associated with the type to be accessed
without a dictionary lookup while keeping this data visible to the
garbage collector. (PR `195 <https://github.com/wjakob/nanobind/pull/195>`__).
* Fixed surprising behavior in enumeration comparisons and arithmetic
(PR `207 <https://github.com/wjakob/nanobind/pull/207>`__):

* 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 ``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
following were previously true but will now evaluate as false:

* ``FooEnum(1) == BarEnum(1)``
* ``FooEnum(1) == 1.2``
* ``FooEnum(1) == "1"``

* Enum ordering comparisons (``<``, ``<=``, ``>=``, ``>``) and
arithmetic operations (when using the :cpp:struct:`is_arithmetic`
annotation) now require that any non-enum operand be a Python number
(an object that defines ``__int__``, ``__float__``, and/or ``__index__``)
and will avoid truncating non-integer operands to integers. Note that
unlike with equality comparisons, ordering and arithmetic operations
*do* still permit two operands that are enums of different types.
Some examples of changed behavior:

* ``FooEnum(1) < 1.2`` is now true (used to be false)
* ``FooEnum(2) * 1.5`` is now 3.0 (used to be 2)
* ``FooEnum(3) - "2"`` now raises an exception (used to be 1)

* Enum comparisons and arithmetic operations with unsupported types
now return `NotImplemented` rather than raising an exception.
This means equality comparisons such as ``some_enum == None`` will
return unequal rather than failing; order comparisons such as
``some_enum < None`` will still fail, but now with a more
informative error.

* ABI version 8.

1.2.0

------------------------------

* Improvements to the internal C++ → Python instance map data structure to improve
performance and address type confusion when returning previously registered instances.
(commit `716354 <https://github.com/wjakob/nanobind/commit/716354f0ed6123d6a19fcabb077b72a17b4ddf79>`__,
discussion `189 <https://github.com/wjakob/nanobind/discussions/189>`__).
* Added up-to-date nanobind benchmarks on Linux including comparisons to Cython.
(commit `834cf3
<https://github.com/wjakob/nanobind/commit/834cf36ce12ffe6470dcffecd21341377c56cee1>`__
and `39e163
<https://github.com/wjakob/nanobind/commit/e9e163ec55de995a68a34fafda2e96ff06532658>`__).
* Removed the superfluous ``nb_enum`` metaclass.
(commit `9c1985 <https://github.com/wjakob/nanobind/commit/9c19850471be70a22114826f6c0edceee99ff40b>`__).
* Fixed a corner case that prevented ``nb::cast<char>`` from working.
(commit `9ae320 <https://github.com/wjakob/nanobind/commit/9ae32054d9a6ad17af15994dc51138eb88f71f92>`__).

1.1.1

-----------------------------

* Added documentation on packaging and distributing nanobind modules. (commit
`0715b2
<https://github.com/wjakob/nanobind/commit/0715b278ba806cf13cf63e41d62438481e7b73b8>`__).
* Made the conversion :cpp:func:`handle::operator bool() <handle::operator
bool>` explicit. (PR `173 <https://github.com/wjakob/nanobind/pull/173>`__).
* Support :cpp:class:`nb::typed\<..\> <typed>` in return values. (PR `174
<https://github.com/wjakob/nanobind/pull/174>`__).
* Tweaks to definitions in ``nb_types.h`` to improve compatibility with further
C++ compilers (that said, there is no change about the official set of
supported compilers). (commit `b8bd10
<https://github.com/wjakob/nanobind/commit/b8bd1086e9b20da8a81a954f03e7947bee5422fd>`__)

1.1.0

-----------------------------

* Added :cpp:func:`size <ndarray::size>`, :cpp:func:`shape_ptr
<ndarray::shape_ptr>`, :cpp:func:`stride_ptr <ndarray::stride_ptr>` members
to to the :cpp:class:`nb::ndarray\<..\> <ndarray>` class. (PR `161
<https://github.com/wjakob/nanobind/pull/161>`__).
* Allow macros in :c:macro:`NB_MODULE(..) <NB_MODULE>` name parameter. (PR
`168 <https://github.com/wjakob/nanobind/pull/168>`__).
* The :cpp:class:`nb::ndarray\<..\> <ndarray>` interface is more tolerant when
converting Python (PyTorch/NumPy/..) arrays with a size-0 dimension that have
mismatched strides. (PR `162
<https://github.com/wjakob/nanobind/pull/162>`__).
* Removed the ``<anonymous>`` label from docstrings of anonymous functions,
which caused issues in MyPy. (PR `172
<https://github.com/wjakob/nanobind/pull/172>`__).
* Fixed an issue in the propagation of return value policies that broke
user-provided/custom policies in properties (PR `170
<https://github.com/wjakob/nanobind/pull/170>`__).
* The Eigen interface now converts 1x1 matrices to 1x1 NumPy arrays instead of
scalars. (commit `445781
<https://github.com/wjakob/nanobind/commit/445781fc2cf2fa326cc22e8fd483e8e4a7bf6cf5>`__).
* The ``nanobind`` package now has a simple command line interface. (commit
`d5ccc8
<https://github.com/wjakob/nanobind/commit/d5ccc8844b29ca6cd5188ffd8d16e034bcee9f73>`__).

1.0.0

------------------------------

* Nanobind now has a logo. (commit `b65d31
<https://github.com/wjakob/nanobind/commit/b65d3b134d8b9f8d153b51d87751d09a12e4235b>`__).
* Fixed a subtle issue involving function/method properties and the IPython
command line interface. (PR `151
<https://github.com/wjakob/nanobind/pull/151>`__).
* Added a boolean type to the :cpp:class:`nb::ndarray\<..\> <ndarray>`
interface. (PR `150 <https://github.com/wjakob/nanobind/pull/150>`__).
* Minor fixes and improvements.

Page 4 of 7

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.