Skip to main content

Adapter which implements a subset of rpds-py using pyrsistent. Mostly meant for PyPy.

Project description

pyrsistent-as-rpds-py

Run tests

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrsistent_as_rpds_py-2.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pyrsistent_as_rpds_py-2.1.0.tar.gz.

File metadata

  • Download URL: pyrsistent_as_rpds_py-2.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pyrsistent_as_rpds_py-2.1.0.tar.gz
Algorithm Hash digest
SHA256 d1438bf3f85eac604afef171d190509048df7b4541dfc1c448100fb1416d7232
MD5 eccd9a0d033a15a1a747e058e2c9873f
BLAKE2b-256 5200ac6cff51d61061c25f5d68f64b5771db8568b834469551283fe84d9af887

See more details on using hashes here.

File details

Details for the file pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyrsistent_as_rpds_py-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f16935a819b1fc52ca2f545cf30004f94a737012153d72f107b4836c8a1ad144
MD5 297bd7ea755d28abc9dbf24c98d7f059
BLAKE2b-256 e78394878ea23d61ac88c26df3679ce17538e19ad80ffb288cb85605c1e26c4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page