Registry / serialization / sentinel

sentinel

JSON →
library1.0.0pypypi✓ verified 83d ago

Create sentinel objects, akin to None, NotImplemented, Ellipsis. Provides a simple way to define unique sentinel values for signaling special conditions (e.g., default arguments, missing data). Current version: 1.0.0. Release cadence: infrequent, stable.

pip install sentinel
INSTALL
IMPORT
SIG · SENTINEL
S
sentinel
serializationpythonv1.0.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 v1.0.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.

create
from sentinel import create
from sentinel import Sentinel
inspect
from sentinel import inspect
Any
from sentinel import Any

Creates a sentinel object to use as a default argument marker.

from sentinel import Sentinel # Create a unique sentinel NotGiven = Sentinel('NotGiven') def get_value(key, default=NotGiven): if default is NotGiven: print('No default provided') else: print(f'Default is {default}') get_value('foo') get_value('foo', default='bar')
Debug
Known issues
gotchaSentinel instances are not singletons by default; each call to Sentinel('name') creates a new instance. Use a module-level constant to maintain identity.
fix
Always assign the sentinel to a module-level variable (e.g., _MISSING = Sentinel('MISSING')) and import that variable.
affects: >=0.1.0
gotchaSentinel objects cannot be pickled by default. Attempting to pickle a sentinel will raise a PicklingError.
fix
If pickling is needed, use sentinel's __reduce__ method or define a custom sentinel class.
affects: >=0.1.0
gotchaSentinel instances compare by identity, not value. Using == may give unexpected results if the sentinel is not the exact same object.
fix
Always use 'is' for comparison, not '=='.
affects: >=0.1.0
Upgrade
Version history
1.0.0latest on PyPI · released Jul 23, 2022
Audit
Dependencies
sixoptionalUsed for Python 2/3 compatibility (though library requires >=3.6, included for historical reasons)
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
sentinel — pip install sentinel · libregistry