Skip to main content

struuuctify

Installation

pip install struuuctify

Rust like struct for python

Define a new struct:

from structify import struct, impl


@struct
class Point:
    x: float
    y: float

And add method implementation on that struct

@impl
def add(
    self: Point,
) -> float:
    return self.x + self.y

You can now instanciate the struct and call the method as if it was defined in the class:

p = Point(1, 2)

p.add()
>> 3

Limitation

This project is more of a gimmick-y pattern and experimentation around rust-like struct in Python !

  • Mypy and type checkers will not be aware of the method declared on your struct as they are added at runtime.
  • If you define methods on the same struct from different locations, you could end up having clash

Metadata

Release files for struuuctify 0.0.4

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

Source distribution (sdist)

Source distribution for struuuctify 0.0.4
File Size Uploaded
struuuctify-0.0.4.tar.gz 6.1 kB Details

Built distribution (wheel)

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

Total release size: 9.6 kB

Release files / struuuctify-0.0.4.tar.gz

Download URL struuuctify-0.0.4.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2257fece78d0dbf69dbd54caf19051f579e664b8df861f854a638677530745ae
BLAKE2b-256 checksum
How to use checksums
077fa1de20bba5013ca0c61b237d8128f4451935f80670cc502d2bb26735e8f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / struuuctify-0.0.4-py3-none-any.whl

Download URL struuuctify-0.0.4-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1570766d958240a83d1f20fd9124cb1816053433c222eb1edc1219d592433f4
BLAKE2b-256 checksum
How to use checksums
49caa4650d414bca893cfff92cf55c9b4aa4f365352b3b18c0cf8100d0d2f13d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.4 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