Skip to content

Draft: Experiment with using nanobind - #32411

Draft
iccir wants to merge 10 commits into
matplotlib:mainfrom
iccir:nanobind-experiment
Draft

iccir wants to merge 10 commits into
matplotlib:mainfrom
iccir:nanobind-experiment

Conversation

@iccir

@iccir iccir commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

PR summary

I'm tinkering with nanobind to re-acquaint myself with C++ after a 20+ year hiatus. This is a draft pull request so I can run CI on my experiments.

Results

Binary Size Comparison

(darwin, arm64)

Extension pybind11 nanobind Δ
_backend_agg 535K
_c_internal_utils 190K 108K -82K
_image 355K
_path 355K
_qhull 571K 498K -73K
_tkagg 211K 126K -85K
_tri 321K 192K -129K
ft2font 2.6M

Compilation Time Comparison

Extension pybind11 nanobind
_backend_agg 5.605s
_c_internal_utils 1.964s 1.177s
_image 3.932s
_path 3.654s
_qhull 3.946s 3.058s
_tkagg 2.139s 1.206s
_tri 3.157s 1.604s
ft2font 18.418s

AI Disclosure

  • I use AI for web search due to search engines becoming less reliable.
  • I used AI to port small snippets of code from pybind to nanobind. I then took the same approach and manually ported sections myself.
  • I used AI for help with the C++ STL.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • [/] New and changed code is tested
  • [/] Plotting related features are demonstrated in an example
  • [/] New features and API changes have release notes
  • [/] Documentation complies with general and docstring guidelines

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant