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. The default wordlist is adapted from better_profanity (MIT).

Metadata

Release files for better-profanity-fast 0.1.0

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.0
File Size Uploaded
better_profanity_fast-0.1.0.tar.gz 21.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for better-profanity-fast 0.1.0
File
better_profanity_fast-0.1.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
better_profanity_fast-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
better_profanity_fast-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
better_profanity_fast-0.1.0-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.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
better_profanity_fast-0.1.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
better_profanity_fast-0.1.0-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.0.tar.gz

Download URL better_profanity_fast-0.1.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5027d1405c552e4e7406cfc8b176b4a94ef05076ef9f379ad18d56f8496aaa48
BLAKE2b-256 checksum
How to use checksums
ce59d7a43db5b61eaec7948bcdb81529686e5bcd581e2e8fd6ec845b880930e7
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.0-cp39-abi3-win_amd64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-win_amd64.whl
Size 234.8 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7a8d488ef11c017bb32329bc2aef23f2187424f15e0200c0c7dc3f5e28568f15
BLAKE2b-256 checksum
How to use checksums
0bd57df22a6ccccdf7a6e5e51881380009052b8910fdd8e140a4bc31f0383591
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.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 584.0 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
56661777ec1d09a8485e4c1c68b66a9be64a68417e3478848567a3db0bd88b6e
BLAKE2b-256 checksum
How to use checksums
c8979ce982c99e867763e53561995b1dc3be552b11a165309d86f8c905e7d863
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.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 552.1 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
f951a550d3bc5d8c3b6f24ccaddacb96126c2dd6cbc0084b1e99bcaa048f6119
BLAKE2b-256 checksum
How to use checksums
1cb1101155421316d731d2f803d64716799dd2764ba0c61880a802a37bfebca9
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.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 382.2 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d629ef033039f262d7602612b82455b710cd1c062dda21c5661f1d0777d75f39
BLAKE2b-256 checksum
How to use checksums
195c81ca0027418bbc7fd3f0ca0097c1a19ef5295c4c9e342cbda5e2cf7c2dd7
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.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 375.6 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f6fd003bdfd5acce5d3b648cf4adb4deb5d2347fbb9c3d83c2bf9cbf9b2e9470
BLAKE2b-256 checksum
How to use checksums
b15ecb8c57facdf82f24662e047e2e06ca05e9ee1e68a11c48f65c10aabb8dc1
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.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 341.0 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
055e030fd430290c513eb28f2e1f58dff9061ff30257b85b182d9eea4907da4f
BLAKE2b-256 checksum
How to use checksums
e18c4cebbf1bff8a1b399522f9e58720085b9e7bf3e4b1e479a2fedcb22194c6
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.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL better_profanity_fast-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 341.1 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
79f035092a37ce5b94dcf044233199847892a33f5248dd40e39a6a3aecb35002
BLAKE2b-256 checksum
How to use checksums
1bee222497447461d5a6d2d90010812302f2b831a0db07ad350cd5f05e9d1d2c
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

0.1.1

8 release files

This release

0.1.0 This release

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