yafwi

Yet Another Fixed Width Integer (Library)
Simple fixed with integers for developer experimentation.
Usage
Installation
Available through yafwi - PyPI using pip install yafwi.
Some Examples
>>> from yafwi import *
>>> from yafwi import __all__
>>> __all__
('FixedWidthInt', 'BaseFixedWidthInt', 'generate_int',
'int8', 'int16', 'int32', 'int64', 'int128', 'int256',
'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',
'sbyte', 'byte', 'short', 'ushort', 'int_', 'uint', 'long', 'ulong')
>>> int8(120)
int8(120)
>>> int8(120) + 120 # Arithmetic with Python int preserves type
int8(-16)
>>> int8(120) + int16(120) # Arithmetic will take result in larger width
int16(240)
>>> int16.max, int16.min # Utility sentinels
(int16(32767), int16(-32768))
>>> uint32.min, uint32.max
(uint32(0), uint32(4294967295))
>>> int8(0b11110000) # Utility represenations
int8(-16)
>>> int8(0b11110000).bin
'0b11110000'
>>> int8(0b11110000).hex
'0xf0'
>>> (~int8(0b10010110)).bin
'0b01101001'
>>> (int8(0b10010110) >> 2).bin
'0b11100101'
>>> (int8(0b10010110) << 2).bin
'0b01011000'
>>> ((uint32(uint8.max) << 10 | uint8.max) ^ uint32.max - (1 << 31)).bin
'0b01111111111111000000001100000000'
>>> bytes(uint32(8)) # Output depends on system byteorder
b'\x08\x00\x00\x00'
>>> uint32(8).hex # Output independent of system byteorder
'0x00000008'
Convenient Aliases
>>> from yafwi import *
>>> uint is uint32
True
>>> long is int64
True
>>> ushort is uint16
True
[...]
Arbitrary Sizes
>>> import yafwi
>>> yafwi.generate_int(1024, unsigned=True)
<class 'yafwi.uint1024'>
>>> yafwi.int512
<class 'yafwi.int512'>
>>> yafwi.int3.max, yafwi.int3.min # Including some fun ones...
(int3(3), int3(-4))
Platform Independence
If run on a big-endian system, the bytes associated with the numbers will be different, but higher-level functionality should remain unchanged.
Metadata
Release files for yafwi 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yafwi-1.0.1.tar.gz | 11.1 kB | Without provenance | Details for yafwi-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yafwi-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for yafwi-1.0.1-py3-none-any.whl |
Total release size: 17.5 kB
Release files / yafwi-1.0.1.tar.gz
| Download URL | yafwi-1.0.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cba3c3956f8d34f43d23a9202d4495b32c0e5f1066859cba9b6f0d325f1e14f9
|
|
BLAKE2b-256 checksum How to use checksums |
39e04f6e3f99ec32877cf585f23703d203fb88ae0eaa8044765bc33451eb4338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b4
|
Release files / yafwi-1.0.1-py3-none-any.whl
| Download URL | yafwi-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94fe2079de3a98792927d5138412f30c1089ee84ac19fc75531bce58dedfcef3
|
|
BLAKE2b-256 checksum How to use checksums |
fe8491f96446f686775317c8a704b397265f17c2f0bf1fbbee3c186060ad5651
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b4
|
Security for yafwi 1.0.1
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.