Skip to main content

better-profanity-fast

Fast better_profanity-compatible profanity filter. Matching runs in Rust; Python is only the public API.

There is no pure-Python fallback. Install a wheel for your OS/CPU, or build from the sdist with a Rust toolchain.

from better_profanity_fast import Profanity

filt = Profanity()  # default wordlist; construct once per process
filt.contains_profanity("he is a m0th3rf*cker")  # True
filt.censor("Dude, I hate shit.")  # 'Dude, I hate ****.'

In Django, create one Profanity() at import / AppConfig ready time. Do not build a new filter on every request.

Benchmark vs better_profanity 0.7

Same process, same 916-word list (wordlist.txt), CPython 3.14 on macOS arm64. Median of 3+ rounds. Speedup is 0.7 time / this package (higher means faster).

0.7 walks a VaryingString list per token, so a ~14k-character paragraph takes ~2.8 seconds. This package hashes leet variants and scans in Rust.

contains_profanity on dirty text early-exits here; 0.7 still scans. Censor always walks the full string on both sides, so the long-censor rows (~3700x) are the fairest like-for-like comparison.

Construct the filter once. Init is slower than 0.7 because we pre-expand leet hashes (~500k) at load time.

Operation Workload better_profanity 0.7 better-profanity-fast Speedup
init 916-word list 2.1 ms 16.5 ms 0.12x
contains_profanity short clean (75 chars) 13.6 ms 5.5 µs 2500x
contains_profanity short profane (57 chars) 7.1 ms 2.0 µs 3500x
contains_profanity short leet (68 chars) 12.6 ms 1.4 µs 9200x
contains_profanity long clean (13884 chars) 2.77 s 746 µs 3700x
contains_profanity long profane (13949 chars) 2.75 s 30 µs 92000x
contains_profanity long leet (13927 chars) 2.77 s 51 µs 54000x
censor short clean (75 chars) 13.5 ms 5.6 µs 2400x
censor short profane (57 chars) 7.1 ms 3.7 µs 1900x
censor short leet (68 chars) 12.5 ms 4.9 µs 2600x
censor long clean (13884 chars) 2.85 s 768 µs 3700x
censor long profane (13949 chars) 2.81 s 764 µs 3700x
censor long leet (13927 chars) 2.80 s 772 µs 3600x

Matching is not identical to 0.7: this package also catches stretched spellings (peenis) and long infixes (ThisRetard). The table still uses the same inputs on both libraries.

Install

pip install better-profanity-fast

Requires CPython 3.9+. Wheels are abi3: one Linux/macOS/Windows wheel covers every CPython version from 3.9 through 3.14. Alpine needs the musllinux wheel (also published).

The default wordlist is wordlist.txt in the Python package, not inside the native library. Swap that file, or set BETTER_PROFANITY_WORDLIST to another path, then construct a new Profanity() — no Rust rebuild.

export BETTER_PROFANITY_WORDLIST=/etc/my-app/wordlist.txt

A dictionary letter may consume at most 8 identical input characters (peenis still matches; 9+ repeats of the same letter do not).

Digit-only tokens (1011, years, ports, order IDs) are never treated as leetspeak. Phrases that happen to contain digits (2 girls 1 cup) still match.

Local development

pip install maturin
maturin develop --release
cargo test --release --lib
python -m unittest discover -s tests -v

License

MIT. Copyright (c) 2026 Eric Carmichael. The default wordlist is adapted from better_profanity (MIT).

Metadata

Release files for better-profanity-fast 0.1.1

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

Source distribution (sdist)

Source distribution for better-profanity-fast 0.1.1
File Size Uploaded
better_profanity_fast-0.1.1.tar.gz 22.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for better-profanity-fast 0.1.1
File
better_profanity_fast-0.1.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
better_profanity_fast-0.1.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
better_profanity_fast-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.8 MB

Release files / better_profanity_fast-0.1.1.tar.gz

Download URL better_profanity_fast-0.1.1.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7f4421aebc98ebfafd55a5e6c5266cf6aca3fd94893930095cfeb516b4e07bef
BLAKE2b-256 checksum
How to use checksums
b1464fec6eb19ff9a474002123bed0178c958bf1d492afd00067465951101256
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-win_amd64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-win_amd64.whl
Size 235.0 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8dc7adab3b947d7fcedc3dcd885cc76d6d18354f1106e106ff73702089d87590
BLAKE2b-256 checksum
How to use checksums
1a03761e70ead78b84b9bb3c1cb8af93af7d47ba5c87c47941dcea3e604a9b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 583.9 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
3aae6f992a3c5d3807186815b4c0937764744e9460b4ec714653cfa35112cdd2
BLAKE2b-256 checksum
How to use checksums
42d87510869da861e516ba533bd678573b517eabb215a481ffa040a30f60b03a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl
Size 552.5 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
37286f78450cbded110b571cd2ee5e8528361e931f479c6eb8d9949b5bf8ec64
BLAKE2b-256 checksum
How to use checksums
e2513d3e579ca67da493d068bb8dd5d616e7a06bbcd6348a0ecf45c3b71e52c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 382.4 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fa048a45bb7cf4acea8b8f666c35af3d4b7c676c090af25b06d8ddf7ceec132a
BLAKE2b-256 checksum
How to use checksums
75e99444f6c8eeed96f2976f19807201306f3d0ec57e156b5ce7e502a4829250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 375.7 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
bb89fc1c8f447b817ab5422300ebf77a9b8e09eeca2fb78b3a5e00058f2fb085
BLAKE2b-256 checksum
How to use checksums
cad0764de64eaffedea6c73bb7f67fed056e3144b3b7cf9012999f61484bcb99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Size 341.1 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1de6687ceb7838bd8e23a615ea3d704b7128bd2740d4081a0e7ec23af6662cd3
BLAKE2b-256 checksum
How to use checksums
40a48c6d832e1283b70e99e399e5480fc0221f12a37477b3759a2afe82d134fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release files / better_profanity_fast-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL better_profanity_fast-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 341.3 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
62eca81d4bb1bb97c6ef86c5f72309f9752efd7b1167a52f14287c7c4a3034f2
BLAKE2b-256 checksum
How to use checksums
1d2585ac4f9e8ecf6495fc71a659e560ef453f27c1608b1eaf0488a2667ceb66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

8 release files

0.1.0

8 release files

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