Skip to main content

polyslice

Extends Python indexing with multiple slices and indices in one operation, concatenating the selections into a new sequence of the original type.

from polyslice import PolySlice
    
data = "0123456789"

a = PolySlice(data)[0:3, 5, -1:-3:-1]
print(a)  # 012578

b = PolySlice(tuple(data))[0:3, 5, -1:-3:-1]
print(b)  # ('0', '1', '2', '5', '9', '8')

c = PolySlice(list(data))[0:3, 5, -1:-3:-1]
print(c)  # ['0', '1', '2', '5', '9', '8']

Interface

To make polyslice work on your own containers, implement:

class MyContainer:

    def __init__(self, iterable=()) -> None:
        ...

    def __iadd__(self, other: Self) -> Self:
        ...

    def __getitem__(self, key: int | slice) -> object | Self:
        ...

Or alternatively, convert to and from polysliceble iterable (tuple, list, ...), by implementing:

class MyContainer:

    def to_iterable(self) -> polysliceble_iterable:
        ...

    @classmethod
    def from_iterable(cls, iterable) -> Self:
        ...

Release files for polyslice 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyslice 0.0.2
File Size Uploaded
polyslice-0.0.2.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polyslice 0.0.2
File Interpreter ABI Platform
polyslice-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / polyslice-0.0.2.tar.gz

Download URL polyslice-0.0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ab7bffeff123cf02b3259bebc055d4f125737456adebd668ca716be32827f21b
BLAKE2b-256 checksum
How to use checksums
424f892969a5ee9f991fe640554314aca8c5a70d4169385076e244ed46655db9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / polyslice-0.0.2-py3-none-any.whl

Download URL polyslice-0.0.2-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
759d52e9fd85df6930243b83c310dbc8bd98b2c9c0acd86799d04ccb4ff5b366
BLAKE2b-256 checksum
How to use checksums
a6b1b5afe07e3479042fa795a2c7f6a07d30923720a5ab2dcdc3f4e51160a2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page