Giter VIP home page Giter VIP logo

rpds's Introduction

rpds.py

PyPI version Supported Python versions Build status

Python bindings to the Rust rpds crate for persistent data structures.

What's here is quite minimal (in transparency, it was written initially to support replacing pyrsistent in the referencing library). If you see something missing (which is very likely), a PR is definitely welcome to add it.

Installation

The distribution on PyPI is named rpds.py (equivalently rpds-py), and thus can be installed via e.g.:

$ pip install rpds-py

Note that if you install rpds-py from source, you will need a Rust toolchain installed, as it is a build-time dependency. An example of how to do so in a Dockerfile can be found here.

If you believe you are on a common platform which should have wheels built (i.e. and not need to compile from source), feel free to file an issue or pull request modifying the GitHub action used here to build wheels via maturin.

Usage

Methods in general are named similarly to their rpds counterparts (rather than pyrsistent's conventions, though probably a full drop-in pyrsistent-compatible wrapper module is a good addition at some point).

>>> from rpds import HashTrieMap, HashTrieSet, List

>>> m = HashTrieMap({"foo": "bar", "baz": "quux"})
>>> m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37})
True
>>> m.remove("foo") == HashTrieMap({"baz": "quux"})
True

>>> s = HashTrieSet({"foo", "bar", "baz", "quux"})
>>> s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"})
True
>>> s.remove("foo") == HashTrieSet({"bar", "baz", "quux"})
True

>>> L = List([1, 3, 5])
>>> L.push_front(-1) == List([-1, 1, 3, 5])
True
>>> L.rest == List([3, 5])
True

rpds's People

Contributors

julian avatar dependabot[bot] avatar pre-commit-ci[bot] avatar andersk avatar here-abarany avatar byron-lambda avatar xiangzhai avatar hroncok avatar wxpppp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.