Comments (10)
The immutable list type will be quite similar to Python's tuple
type. But, tuple + tuple
is an O(n) operation, while extending an immutable list (or concatenating two immutable lists) will be a (O log32 N) operation.
from immutables.
Not in the foreseeable future, unfortunately. PRs are welcome, though :)
from immutables.
How would an immutable list type differ from Python's tuple?
from immutables.
Not in the foreseeable future, unfortunately. PRs are welcome, though :)
I would like to work on this. I think about an implementation using fingertrees. Any advice?
from immutables.
I would like to work on this.
Great!
I think about an implementation using fingertrees. Any advice?
Is that what say Clojure uses? The current HAMT implementation was hugely inspired by Clojure's map implementation, so it would be great to study how they handle vectors.
from immutables.
HAMT is mostly the preferred way to implement mapping with Scheme.
I am not very familiar with Clojure. I found about that library https://github.com/clojure/data.finger-tree.
I investigated, and asked for advice around. finger trees have a good amortized complexity. The important word is "amortized", in other words it is a hit or miss in terms of performance if you randomly get something in the middle of the list. AFAIU, only the beginning and the end of the list can have predictable performance. Finger-trees were invented around Haskell that has great facility for delayed computation, it is optimized for that, since the default behavior is lazy. And AFAIK / AFAIU it is different with Python (it is possible, but not optimized). Finger trees are said to be a generic toolkit to create immutable data structures, is not false, but it requires at the very least benchmarks to be able to tell whether it is useful in practice.
I was said to go with a binary-tree with a log measure to implement an indexed immutable list. The problem with that approach is that it is very mathy stuff, or hackish. It sound to me like a hack similar to how to compute a hash in the implementation of an hash-table. The advantage is that it is easier to implement than finger trees. Also, the research debate is focused on the measure used tell whether the tree is balanced or not, ie. changing the measure (which happened twice over a couple of decades), is backward compatible and easy to do.
Also, the binary search tree approach allows to implement ordered mappings 💌.
I am not sure whether I will do it. I will post here if/when I have something useful.
from immutables.
@amirouche sounds good. Although let me explicitly say that I wouldn't want to replace the current HAMT implementation for maps with something else. Using new algos to implement new types should be OK though.
from immutables.
pyrsistent is a full-featured python immutable data structure library. It has a persistent vector type implemented in C. It's funny that pyrsistent lacks a C versioned map type(Its immutable map is implemented in python). Seems pyrsistent and immutables can complete each other.
from immutables.
I started implementing ordered mappings at https://github.com/amirouche/lbst/blob/c6c913a68d02108a106382543f9648d3f4a3be83/README.md
from immutables.
For more information about ordered mappings look at https://okvs.dev
from immutables.
Related Issues (20)
- How about comparing performance to frozen dict?
- 3.12 support HOT 3
- Adding support for shared_memory allocator for multiprocessing.
- pythoncapi_compat.h is 0BSD not MIT HOT 1
- sdist is missing tests/test-data/check-immu.test
- Segfault with Python 3.13.0b1 HOT 1
- immutables._map.MapMutation is not iterable / does not implement items() HOT 3
- Binary wheels for Python 3.9 HOT 4
- Maintain Map insertion order like dict on Python 3.7+ HOT 2
- Add support to release aarch64 wheels HOT 1
- [Security] Potential Secret Leak HOT 1
- Potential buffer-overflow in map_node_array_assoc of _map.c
- 0.16: pytest is failing HOT 22
- How to efficiently track and store deltas between two HAMTs HOT 1
- Unable to install from sdist: pyproject.toml [project] requires a name. HOT 3
- Do you want my frozenset implemenation using this lib?
- Map type arguments aren't introspectible in runtime
- Iteration bug HOT 2
- Invalid pyproject.toml HOT 1
- Pattern matching isn't working for C implementation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutables.