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)
| File | Size | Uploaded | |
|---|---|---|---|
| struuuctify-0.0.4.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|