Registry / serialization / ordered-enum

ordered-enum

JSON →
library0.0.10pypypi✓ verified 84d ago

A small library for adding total orderings to enums, providing an OrderedEnum base class that supports comparison operators (<, <=, >, >=) based on member definition order. Version 0.0.10, released in 2024, requires Python >=3.9. Maintained with infrequent releases.

pip install ordered-enum
INSTALL
IMPORT
SIG · ORDERED-ENUM
O
ordered-enum
serializationpythonv0.0.10
Install
1.8s 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 v0.0.10 · 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.8s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

OrderedEnum
from ordered_enum import OrderedEnum
from ordered_enum import OrderedEnum as OE
Correct import path is 'ordered_enum' (with underscore), not 'ordered_enum'.

Define an enum with ordered comparisons based on member declaration order.

from ordered_enum import OrderedEnum class Color(OrderedEnum): RED = 0 GREEN = 1 BLUE = 2 assert Color.RED < Color.GREEN assert Color.BLUE > Color.RED print("Ordering works!")
Debug
Known issues
breakingComparison operators (<, <=, >, >=) only work between members of the same OrderedEnum subclass. Comparing across different OrderedEnum subclasses raises TypeError.
fix
Ensure comparisons only within the same enum class.
affects: >=0.0.1
gotchaOrderedEnum does not support integer comparison with enum values. For example, Color.RED < 1 will raise TypeError. This is by design and differs from Python's standard IntEnum.
fix
Use the .value attribute for numeric comparisons: Color.RED.value < 1.
affects: >=0.0.1
deprecatedThe package is not actively maintained; no updates since 2024. Consider alternatives like stdlib IntEnum if integer ordering is needed.
fix
For simple ordered enums, use Python's IntEnum with auto() and custom ordering, or use another library.
affects: all
Errors
Common errors & fixes
AttributeError: module 'ordered_enum' has no attribute 'OrderedEnum'
Mistyped import: using 'ordered-enum' (hyphen) or misspelling
fix
Use correct import: from ordered_enum import OrderedEnum
TypeError: '<' not supported between instances of 'Color' and 'Color'
Attempting comparison between two different OrderedEnum subclasses or between OrderedEnum and a non-enum value.
fix
Ensure both operands are members of the same OrderedEnum subclass.
Upgrade
Version history
0.0.10latest on PyPI · released Jun 23, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
ordered-enum — pip install ordered-enum · libregistry