Overview
PyReprism is a Python framework for source-code preprocessing. It lets you match, extract, count, and remove comments, strings, numbers, operators, keywords and other language-specific constructs across 187+ programming languages and file formats (500+ with the optional Pygments backend) — through a small high-level API, a command-line tool, code metrics, ML-oriented normalization, and diff/pull-request analysis.
Everything is derived from one lossless token stream, and the same substrate anchors a fidelity ladder of optional-cost tiers: a zero-dependency lexical tier (default), an optional syntactic tier (tree-sitter ASTs for precise per-function metrics), and an optional semantic tier (code embeddings for Type-4 clone detection).
Highlights
One consistent API for every language: remove_* / extract_* / count_* / match_* for each construct, plus a lossless tokenize().
Code metrics (stats) and ML canonicalization (normalize) for clone/plagiarism detection and code-embedding pipelines.
Optional high-accuracy Pygments backend and an on-demand Pygments fallback for 500+ languages — with zero required dependencies by default.
Optional syntactic (AST) and semantic (embedding) tiers for precise per-function metrics and Type-4 clone detection.
Located clone detection with console, JSON, SARIF, Markdown, and HTML reports and a duplication gate for CI (also as a GitHub Action).
Batch/corpus analysis on every core, and unified/git diff processing.
A pyreprism command-line tool (also python -m PyReprism).
Stability
PyReprism 1.0 is the first stable release. From 1.0 on, releases follow semantic versioning: the public API and the pyreprism command line change incompatibly only in a new major version. Modules whose names start with an underscore are internal. Token classifications may still change in minor releases when they fix a lexer defect; the changelog lists every such change.
Requirements
Python 3.8 or newer
Install
pip install PyReprism
The optional tiers are opt-in extras (install only what you need):
pip install "PyReprism[accurate]" # Pygments backend (higher lexical fidelity)
pip install "PyReprism[ast]" # syntactic tier (tree-sitter)
pip install "PyReprism[semantic]" # semantic tier (code embeddings)
Quick start
import PyReprism as pr
source = """
# a comment
x = 5 + 6
print(x) # inline
"""
pr.remove_comments(source, lang="python") # code without comments
pr.extract_comments(source, lang="python") # ['# a comment', '# inline']
pr.count_comments(source, lang="python") # 2
lang accepts a language name ("python"), a file extension (".py"), or a language class. Canonicalize code for machine learning, or measure it:
pr.normalize("total = price * 42", lang="python") # 'VAR1 = VAR2 * 0'
pr.stats(source, lang="python").comment_to_code_ratio
Command line
pyreprism remove comments file.py
pyreprism scan myproject/ --csv # aggregate code metrics over a tree
git diff | pyreprism diff --cosmetic # flag comment/whitespace-only changes
pyreprism clones src/ --max-duplication 5 # located clones; fail above 5%
Documentation
Full documentation, including the API reference and the list of supported languages, is available at https://pyreprism.readthedocs.io.
Source code
PyReprism is developed on GitHub at https://github.com/unlv-evol/PyReprism. To work on it locally:
git clone https://github.com/unlv-evol/PyReprism.git
cd PyReprism
python3 -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest
See CONTRIBUTING.md for contribution guidelines.
Metadata
Release files for PyReprism 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyreprism-1.0.0.tar.gz | 133.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyreprism-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 338.9 kB
Release files / pyreprism-1.0.0.tar.gz
| Download URL | pyreprism-1.0.0.tar.gz |
|---|---|
| Size | 133.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5821c92ba3433a4dfcdebdf70fee58e3107785552221e6822a87402b3ec600e
|
|
BLAKE2b-256 checksum How to use checksums |
f2c8d46462b35ffb216d751ff181b903c0bac5123426dd538163af0784e15f3e
|
| 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 Oct 12, 2026.
Transparency logRelease files / pyreprism-1.0.0-py3-none-any.whl
| Download URL | pyreprism-1.0.0-py3-none-any.whl |
|---|---|
| Size | 205.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
718c247073c0c5a3c68d986c25990d3dfc881c3c5f9ace04cf82cecfdc3a3699
|
|
BLAKE2b-256 checksum How to use checksums |
307aa95b0bf0ba121122ad3f76fba0a66a64de1ef1cef0c35b6b7bb3d7481931
|
| 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 Oct 12, 2026.
Transparency log