tobgu / pyrsistent

Persistent/Immutable/Functional data structures for Python
MIT License
2.03k stars 147 forks source link

Best way to insert multiple elements into a `pvector`? #290

Open ornamentist opened 3 months ago

ornamentist commented 3 months ago

Is there a recommended way to insert multiple elements at a position in a pvector? The equivalent of the following Python list code:

>>> xs = [1, 2, 6, 7]
>>> xs[2:2] = [3, 4, 5]
>>> xs
[1, 2, 3, 4, 5, 6, 7]

I can see I could join three pvectors if necessary: a prefix vector, the inserted elements and a suffix vector but I figure there's probably a better way?