Registry / serialization / roman-numerals

roman-numerals

JSON →
library4.1.0pypypi✓ verified 27d ago

The `roman-numerals` library provides utilities to manipulate well-formed Roman numerals, including converting between integers and Roman numeral strings. The current version is 4.1.0, and it generally sees major releases annually with minor updates as needed.

pip install roman-numerals
INSTALL
IMPORT
SIG · ROMAN-NUMERALS
R
roman-numerals
serializationpythonv4.1.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RomanNumeral
from roman_numerals import RomanNumeral
from roman_numerals import Roman

Demonstrates converting integers to Roman numerals and vice-versa using both the `Roman` class and the utility functions `to_roman` and `from_roman`.

from roman_numerals import Roman, to_roman, from_roman # Using the Roman class roman_four = Roman(integer=4) print(f"Roman(integer=4): {roman_four} (integer: {roman_four.integer})") roman_ninety = Roman(string='XC') print(f"Roman(string='XC'): {roman_ninety} (integer: {roman_ninety.integer})") # Using direct functions converted_to_roman = to_roman(1994) print(f"to_roman(1994): {converted_to_roman}") converted_from_roman = from_roman('MCMXCIV') print(f"from_roman('MCMXCIV'): {converted_from_roman}")
Debug
Known issues
breakingThe `Roman` class constructor arguments changed from positional to keyword-only. Previously, `Roman('IV')` or `Roman(4)` was valid. Post-3.0.0, you must use keyword arguments like `Roman(string='IV')` or `Roman(integer=4)`.
fix
Update `Roman` class instantiations to use `string=` or `integer=` keyword arguments.
affects: >=3.0.0
breakingThe `Roman` class constructor logic was refined. If both `integer` and `string` keyword arguments are provided, `integer` now takes precedence. Additionally, an empty string (`''`) for the `string` argument will now result in a `Roman` object representing `None`.
fix
Review code where both `integer` and `string` might be passed to the `Roman` constructor, ensuring the desired precedence. Be aware of `Roman(string='')` behavior.
affects: >=4.0.0
gotchaThe library primarily supports Roman numerals representing integers from 1 to 3999 (inclusive). Inputs outside this range for integers, or malformed Roman numeral strings, will raise `ValueError`.
fix
Validate input integers are within the 1-3999 range before conversion. Handle `ValueError` for invalid Roman numeral strings.
affects: All versions
breakingThe `Roman` class was introduced, and the `to_roman` and `from_roman` functions were moved to be directly importable from the top-level `roman_numerals` package. Earlier versions might have required different import paths or not had the `Roman` class.
fix
Ensure imports for `to_roman` and `from_roman` are directly from `from roman_numerals import ...`. Utilize the `Roman` class for object-oriented manipulation.
affects: >=2.0.0
Upgrade
Version history
4.1.0latest on PyPI · released Dec 17, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
roman-numerals — pip install roman-numerals · libregistry