Install & Compatibility
Where this runs
tested against v5.4 · 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
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.7s · import 0.084s · 24MB
22MB installed
● package 22MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Persistent
✓ from Persistence import Persistent
✗ from persistent import Persistent
The `persistent` library provides a more general `Persistent` class. This `Persistence` library provides an ExtensionClass variant. Use the `persistent` library if ExtensionClass semantics are not needed.
Defines a basic persistent class using `Persistence.Persistent`. Note that for true persistence, this class needs to be instantiated and managed within a ZODB (Zope Object Database) context, which typically involves setting up a storage and connection.
from Persistence import Persistent
class MyPersistentObject(Persistent):
def __init__(self, value):
self.value = value
self.data = []
def add_data(self, item):
self.data.append(item)
# In a real ZODB application, this object would be managed by a Connection/Database.
# Example: (requires ZODB setup, not runnable standalone for full persistence)
# from ZODB import DB, FileStorage
# import transaction
#
# storage = FileStorage.FileStorage('my_data.fs')
# db = DB(storage)
# conn = db.open()
# root = conn.root()
#
# if 'my_obj' not in root:
# root['my_obj'] = MyPersistentObject('initial_value')
# transaction.commit()
#
# obj = root['my_obj']
# print(f'Initial value: {obj.value}, Data: {obj.data}')
# obj.add_data('new_item')
# obj.value = 'updated_value'
# transaction.commit()
#
# print(f'Updated value: {obj.value}, Data: {obj.data}')
# conn.close()
# db.close()
Debug
Known issues
gotchaThe `Persistence` library provides a `Persistent` class that is an ExtensionClass. If you do not specifically require ExtensionClass semantics, it is recommended to use `persistent.Persistent` from the `persistent` distribution, which is the more common and general-purpose persistence base class.fixEvaluate your project's needs. If ExtensionClass is not a strict requirement, consider `pip install persistent` and `from persistent import Persistent` instead.
affects: All versions
breakingThis standalone `Persistence` release (and its related `persistent` package) is not recommended or supported with ZODB versions older than 3.11. ZODB 3.10 and earlier versions bundled their own internal version of the `persistent` package, which can lead to conflicts.fixEnsure your ZODB installation is version 3.11 or newer if you intend to use it with this standalone `Persistence` library. If using an older ZODB, rely on its bundled persistence mechanisms.
affects: < 5.0 (for standalone use with ZODB < 3.11)
breakingVersion 5.0 of `Persistence` (and the closely related `persistent` library) dropped support for older Python versions, specifically Python 2.7, 3.5, and 3.6.fixUpgrade your Python environment to 3.10 or newer (Persistence 5.4 requires >=3.10) to use `Persistence` version 5.0 or later.
affects: < 5.0
deprecatedThe function `persistent.cPersistence.simple_new` was removed in version 6.1 of the `persistent` library. While this is specifically for `persistent`, users migrating or confusing the two packages might encounter this if they relied on this function with older `persistent` versions.fixAvoid using `persistent.cPersistence.simple_new`. If migrating from older code, review its usage and replace it with appropriate object instantiation patterns.
affects: persistent >= 6.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'Persistence'
The `Persistence` package is not installed in the current Python environment, or the environment is not active.
fixEnsure the package is installed: `pip install Persistence`. If using a virtual environment, ensure it is activated.
AttributeError: 'MyObject' object has no attribute '_p_oid'
This error typically occurs when an object intended to be persistent (inheriting from `Persistence.Persistent`) is instantiated or used outside of a properly initialized ZODB connection, or its persistence state is not correctly managed.
fixEnsure objects inheriting from `Persistence.Persistent` are instantiated and operated upon within the context of an active ZODB database connection and managed by a ZODB Storage/Connection.
TypeError: object of type 'Persistence.Persistent' is not JSON serializable
Instances of `Persistence.Persistent` (or any custom class inheriting from it) are not natively JSON serializable. Attempting to directly serialize these objects using `json.dumps()` will fail.
fixImplement custom JSON serialization for your persistent objects. This usually involves defining a `__json__` method or providing a custom `json.JSONEncoder` that knows how to convert your persistent object into a JSON-serializable dictionary or other basic types.
Upgrade
Version history
5.4latest on PyPI · released Nov 16, 2025
Audit
Dependencies
No dependency data recorded yet.