pyrsistent-as-rpds-py
what is this?
This is a thin adapter library which implements a subset of rpds-py using pyrsistent. The provided functionality is sufficient to run the jsonschema test cases successfully.
why is this?
In 2023, the jsonschema devs replaced the pure-Python pyrsistent library dependency with a binary dependency called rpds-py. This replacement was done in order to improve performance (as CPython is quite slow). However, PyPy users may still prefer the pure-Python version both for speed reasons and also to avoid the hassle of building binary packages.
(The rpds-py API also just feels better than the pyrsistent one, in my humble opinion. If I wanted to build something with persistent data structures, I would probably either use this module or rpds-py.)
how to use
use case 1: I can't use rpds-py for whatever reason, some other package requires it, and I need a drop-in replacement
Pip doesn't seem to have a way to override or substitute dependencies (at least without disabling dependency resolution entirely). Therefore, I suggest running something like this:
# install package "pyrsistent-as-rpds-py"
pip install --no-index --no-build-isolation .
# install fake "rpds" package to make pip happy
cd extra/fake_rpds
pip install --no-index --no-build-isolation .
Now you can install jsonschema or other packages that depend on rpds-py normally.
use case 2: I am developing a new project and I need a persistent data structures library
Just add pyrsistent-as-rpds-py to your requirements.txt / pyproject.toml dependencies like you would any other dependency. Then you can write:
from pyrsistent_as_rpds.auto import List
lst = List(1, 2, 3)
print(lst.rest)
This will try to import the original rpds-py module first. If it fails (because rpds-py is not installed), then it use the pure Python version instead.
This library needs at least one of rpds-py or pyrsistent to be installed. If you are an end-user application packager / system integrator, you must choose to install either pyrsistent-as-rpds-py[pyrsistent] or pyrsistent-as-rpds-py[rpds-py]. This is unfortunately necessary because pip does not support alternative dependencies (e.g., require either X or Y to be installed).
Metadata
Release files for pyrsistent-as-rpds-py 2.1.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 | |
|---|---|---|---|
| pyrsistent_as_rpds_py-2.1.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / pyrsistent_as_rpds_py-2.1.0.tar.gz
| Download URL | pyrsistent_as_rpds_py-2.1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1438bf3f85eac604afef171d190509048df7b4541dfc1c448100fb1416d7232
|
|
BLAKE2b-256 checksum How to use checksums |
5200ac6cff51d61061c25f5d68f64b5771db8568b834469551283fe84d9af887
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl
| Download URL | pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f16935a819b1fc52ca2f545cf30004f94a737012153d72f107b4836c8a1ad144
|
|
BLAKE2b-256 checksum How to use checksums |
e78394878ea23d61ac88c26df3679ce17538e19ad80ffb288cb85605c1e26c4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|