Skip to main content

nbstripout-fast

PyPI version PyPI DM Github Actions Status

A much faster version of nbstripout by writing it in rust (of course). This helps strip Jupyter Notebook output and metadata from notebooks. It is very useful as a git filter and is highly configurable.

Installation

pip install nbstripout-fast

Then replace nbstripout-fast with anywhere you use nbstripout.

Key differences

  1. While we mirrored most of nbstripout's API, we do not support every nbstripout option.
  2. There is no CLI option to install this in git for you
  3. We support repository level settings in a .git-nbconfig.yaml file. Check out our examples. On a high level, you can add a git filter in a sitewide/user level and then allow each project to enforce consistent settings.

Why Rust?

nbstripout is a excellent project, but the python startup and import time makes its usage at scale a bit painful. While this means giving up on using nbconvert under the hood and ensuring the notebook is the correct format, it does make things up to 200x faster. This matters when you have a large number of files and git filter is called sometimes more than once per file. Let's look at the data:

Cells nbstripout nbstripout_fast
1 0m0.266s 0m0.003s
10 0m0.258s 0m0.003s
100 0m0.280s 0m0.004s
1000 0m0.372s 0m0.013s
10000 0m1.649s 0m0.133s

The table above shows a large overhead per notebook (mostly python startup time). When you have 100 or more notebooks, nbstripout takes more than 40s while nbstripout-fast takes only 1s!

Example

This example illustrates how nbstripout-fast can be used to automatically clean Jupyter notebooks using Git filters (see e.g. Git Attributes). This keeps your repository clean by removing unnecessary output and clutter, while preserving your local working version. The benefits are minimised diffs and reduced repository size.

  1. Install nbstripout-fast as described above.

  2. Configure nbstripout-fast

    Create a .git-nbconfig.yaml file at the root of your repository to configure nbstripout-fast, e.g.

    nbstripout_fast:
      keep_count: false
      keep_output: false
      drop_empty_cells: true
      extra_keys: []
      keep_keys: []
    
  3. Set Git Attributes

    Create a .gitattributes file at the root of your repository if it doesn't yet exist and add this line:

    *.ipynb filter=jupyter
    

    This instructs Git to use a custom filter named "jupyter" on all .ipynb files.

  4. Configure the jupyter Filter

    Run these commands in your terminal to configure the "jupyter" filter:

    git config filter.jupyter.clean nbstripout-fast
    git config filter.jupyter.smudge cat
    
  • clean: This filter runs nbstripout-fast when adding notebooks to the version that is checked out, i.e. the clean version.
  • smudge: This filter runs cat when checking out notebooks, ensuring your local (smudged) version remains unmodified. Git filters transform files at the time of checkout and commit.
  1. Reapply Cleaning to Existing Notebooks (Optional)

    If you already have Jupyter notebooks tracked by Git, you can reapply the cleaning process to them:

    git add --renormalize . git commit -m "Cleaned Jupyter notebooks"
    

Stripping specific cell outputs

To strip cell outputs that match a regular expression, the --strip-regex option can be used in combination with --keep-output. For example, to remove cell outputs that only contain a notebook widget:

nbstripout-fast --keep-output --strip-regex "^Output\(\)$"

or to remove completed tqdm progress bars:

nbstripout-fast --keep-output --strip-regex "100%.*"

See the documentation for regex for information about supported regex syntax.

Developing

You can use cargo which will build + run the CLI:

cargo run -- -t examples/example.ipynb

You can also build with cargo and run the script with the full path:

cargo build # dev build - ./target/debug/nbstripout-fast
cargo build --release # release build - ./target/release/nbstripout-fast

Running unit tests: maturin builds this repo to include pyo3 bindings by default. This allows for us to have an extension python extension mode as well. As of today, we can't have a binary and an extension, so we use the extension only for testing (issue).

pip install -e .
maturin develop
# Should output, this way you can use RUST_LOG=debug
in-venv pytest -rP

Debugging

Use RUST_LOG=debug to debug script for example:

RUST_LOG=debug cargo run -- '--extra-keys "metadata.bar cell.baz" -t foo.ipynb'

Releasing

Manylinux, macos, and windows wheels and sdist are built by github workflows. Builds are triggered upon the creation of a pull request, creating a new release, or with a manual workflow dispatch. The wheels and sdist are only uploaded to PyPI when a new release is published. In order to create a new release:

  1. Create a commit updating the version in Cargo.toml and CHANGELOG.md, then create a git tag:
git tag vX.Y.Z
git push --tags
  1. Draft a new release in github; select the tag that you just created.
  2. Once the new release is created, the wheels and sdist will be built by a github workflow and then uploaded to PyPI automatically using the PYPI_API_TOKEN in the github secrets for the repository.

History

This plugin was contributed back to the community by the D. E. Shaw group.

D. E. Shaw Logo

License

This project is released under a BSD-3-Clause license.

We love contributions! Before you can contribute, please sign and submit this Contributor License Agreement (CLA). This CLA is in place to protect all users of this project.

Metadata

Release files for nbstripout-fast 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbstripout-fast 1.1.2
File Size Uploaded
nbstripout_fast-1.1.2.tar.gz 28.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for nbstripout-fast 1.1.2
File
nbstripout_fast-1.1.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
nbstripout_fast-1.1.2-py3-none-win32.whl Python 3 none Windows x86-32 Details
nbstripout_fast-1.1.2-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
nbstripout_fast-1.1.2-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
nbstripout_fast-1.1.2-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
nbstripout_fast-1.1.2-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
nbstripout_fast-1.1.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 8.8 MB

Release files / nbstripout_fast-1.1.2.tar.gz

Download URL nbstripout_fast-1.1.2.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5a5738b0b35211c2830ad3a432639f209473514564483cfcc9da55e7b87f8843
BLAKE2b-256 checksum
How to use checksums
a5e24f811cef01e9d407c26bd543c01d94247d4016128fda884ff22698c0edab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-win_amd64.whl

Download URL nbstripout_fast-1.1.2-py3-none-win_amd64.whl
Size 1.1 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
e35b8cd67deb41613dcbe86f259157763de15b510274a5c7029f26574d6acd5f
BLAKE2b-256 checksum
How to use checksums
0824db0352dba3eabf6cbedddd4260595329aed64d4264957beb16fb32b585a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-win32.whl

Download URL nbstripout_fast-1.1.2-py3-none-win32.whl
Size 1.0 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
6629ee7a568de23d1eb6beba8ebf93ee5b8abe809a696f095a6f724a6d1dce93
BLAKE2b-256 checksum
How to use checksums
9ca3e2915b31c16eeacdd0d8702e5f27845fd16c10f3542a35cc14152748cd47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-musllinux_1_2_x86_64.whl

Download URL nbstripout_fast-1.1.2-py3-none-musllinux_1_2_x86_64.whl
Size 1.4 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
5cd63824e747a1d95b3c3b9ffaa0dc673883295ce24e35df5cc0de1dda5de939
BLAKE2b-256 checksum
How to use checksums
27e35bf934adc82a4759f7343a6ed3da695166a508d56444b8be0df42b0981c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-musllinux_1_2_aarch64.whl

Download URL nbstripout_fast-1.1.2-py3-none-musllinux_1_2_aarch64.whl
Size 1.3 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
e0efb96b48c01100e3f3f3dc7366b235ff1e4e7f1f26cdc54484f800fe87e6aa
BLAKE2b-256 checksum
How to use checksums
9924d0f6d6bc9d009d48d2d2233ab7bdfaec31127f9aca9b60c195b3ee90a5d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-manylinux_2_28_x86_64.whl

Download URL nbstripout_fast-1.1.2-py3-none-manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
49f2e53a2a31007e6f3e9bd21bf88681a32f8957824d474ac308607c838757a0
BLAKE2b-256 checksum
How to use checksums
4f104332c3b8a7e08690963e005ba2c31c8976d97e92bea8f26371b05ea3e1a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-manylinux_2_28_aarch64.whl

Download URL nbstripout_fast-1.1.2-py3-none-manylinux_2_28_aarch64.whl
Size 1.3 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
25798de286d9455b1d4cd1e7e96e7d912ecea63e198ba27db0c7736c123f6707
BLAKE2b-256 checksum
How to use checksums
8a68abf62ad4fff5b23d24870102e3b605bab6a57aa8c53c0b6cfbb687b436d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / nbstripout_fast-1.1.2-py3-none-macosx_11_0_arm64.whl

Download URL nbstripout_fast-1.1.2-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f5d0314f02e3c3eafe871c9f3080c5890b020f7901c442ed672fc5c2b02be0e6
BLAKE2b-256 checksum
How to use checksums
76299a4fc34feaeadaec7193deaf2321e789242a60cc209e32064da12a1b932e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.2 This release

8 release files

1.1.1

7 release files

1.1.0

7 release files

1.0.4

7 release files

1.0.3

7 release files

1.0.2

16 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page