Immutable Map, compatible with JAX & Equinox
Project description
xmmutablemap
Jax-compatible Immutable Map
JAX prefers immutable objects but neither Python nor JAX provide an immutable
dictionary. 😢
This repository defines a light-weight immutable map
(lower-level than a dict) that JAX understands as a PyTree. 🎉 🕶️
Installation
pip install xmmutablemap
Documentation
xmutablemap
provides the class ImmutableMap
, which is a full implementation
of
Python's Mapping
ABC.
If you've used a dict
then you already know how to use ImmutableMap
! The
things ImmutableMap
adds is 1) immutability (and related benefits like
hashability) and 2) compatibility with JAX
.
from xmmutablemap import ImmutableMap
print(ImmutableMap(a=1, b=2, c=3))
# ImmutableMap({'a': 1, 'b': 2, 'c': 3})
print(ImmutableMap({"a": 1, "b": 2.0, "c": "3"}))
# ImmutableMap({'a': 1, 'b': 2.0, 'c': '3'})
Development
We welcome contributions!
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
xmmutablemap-0.1.tar.gz
(11.0 kB
view hashes)
Built Distribution
Close
Hashes for xmmutablemap-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9334ea1963c16258aca77acd8b3f0ebede24743f71cc591c856753d30131e2ab |
|
MD5 | 33dd2cf66baf96a6e164c5caea7478c2 |
|
BLAKE2b-256 | 56e854c83bb090fbe711f0bad4cfd2a17274b137389dbca6f136669f8e19fecb |