Adapter which implements a subset of rpds-py using pyrsistent. Mostly meant for PyPy.
Project description
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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrsistent_as_rpds_py-2.0.0.tar.gz.
File metadata
- Download URL: pyrsistent_as_rpds_py-2.0.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ca53409fd3039e3d19f8c86e918bd60f7de7072346d9d9fe3bc1df9c6de015f
|
|
| MD5 |
925c8c2c9e44690fe37f63eb66a1716b
|
|
| BLAKE2b-256 |
307f29224422d81703b6b44976a39c306db27e12958435ae90f475a5ac310df8
|
File details
Details for the file pyrsistent_as_rpds_py-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pyrsistent_as_rpds_py-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36542ad3f510eac2bbd46a44242a78c687759d44ff52b6649ae5945a5e27add5
|
|
| MD5 |
ef23363dce3ee811016ee6cf020e3cab
|
|
| BLAKE2b-256 |
67f6aa3e8a532b6c8501fa0c14ecb964a1a55bebf0cb3792e254334d10c44928
|