Skip to main content

indexed_meta

Python metaclass with support for per-class specialization via an index method.

Adds a __param__ field to classes programmatically so that you can store a static field on them without having to define a new class and without having to use a new name.

from indexed_meta import IndexedMetaclass  # Base type but either will work fine
from indexed_meta import IndexedClass  # Convenience type. Fixes repr(), str()

class Vec(IndexedClass):
    def show(self):
        # This is the value-add for this library. Use __param__ as you see fit.
        # It is different per specialized class but the exact same when param is
        # the same: Vec[1] == Vec[1]; Vec[1] != Vec[2]
        print(self.__param__)

v1 = Vec[3]()
v1.show()  # Prints `3`

Vec[1], Vec[2], Vec[3], Vec[1, 2, 3], Vec[frozenset([1, 2, 3])]

# It's possible to override the default __param__ of None by inheriting from a
# specialized class:
class Vec(metaclass=IndexedMetaclass):
    ...

class Vec4(Vec[4]):
    ...

assert Vec4.__param__ == 4  # Normally it would be `None`

Metadata

Release files for indexed-meta 0.0.5

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

Source distribution (sdist)

Source distribution for indexed-meta 0.0.5
File Size Uploaded Provenance Actions
indexed_meta-0.0.5.tar.gz 3.7 kB Without provenance Details for indexed_meta-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for indexed-meta 0.0.5
File Interpreter ABI Platform Actions
indexed_meta-0.0.5-py3-none-any.whl Python 3 none any Details for indexed_meta-0.0.5-py3-none-any.whl

Total release size: 8.0 kB

Release files / indexed_meta-0.0.5.tar.gz

Download URL indexed_meta-0.0.5.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3b5d56232291fca6aa451ca01983e25213d1bce366612d6c465d81f00459699c
BLAKE2b-256 checksum
How to use checksums
91f62bb4127edd2188ceeeba1a2f05be468c0a648bb9f5122162e2190351374f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / indexed_meta-0.0.5-py3-none-any.whl

Download URL indexed_meta-0.0.5-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2737a971c9e4c502f211e9528cb048ccf76ed03180ad710211b9860a31f11d9f
BLAKE2b-256 checksum
How to use checksums
cc70d37d0a8082ca253f06e9d52284f3e17252cecad6e7296c0ccfe851c7dad8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for indexed-meta 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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