Python bindings for the Uiua programming language.
Project description
PyUiua
A Python binding for Uiua, allowing interaction between Uiua and Python.
Requirements
- Python 3.10 or higher
Installation
pip install pyuiua
or see dev setup below for building from source
Example Usage
Eval method
import pyuiua
pyuiua.eval("+ 1 2") # 3
pyuiua.eval("/+", [1, 2, 3]) # 6
pyuiua.eval("/×⇡₁10") # 3628800 (10 factorial)
pyuiua.eval("∩+", 1, 2, 3, 4) # (3, 7)
Persisted instance
import pyuiua
uiua = pyuiua.Uiua()
# Push Python values onto the stack and operate on them
uiua.push(10)
uiua.push(20)
uiua.run("+")
print(uiua.pop()) # 30
# Work with arrays
uiua.push([1, 2, 3, 4, 5])
uiua.run("/+")
print(uiua.pop()) # 15
# Inspect the stack
uiua.push(1)
uiua.push(2)
uiua.push(3)
print(uiua.stack()) # [1, 2, 3]
print(len(uiua)) # 3
# Clear the stack
uiua.clear()
API Reference
pyuiua.eval(code, *args) - Run Uiua code with any number of inputs and return the resulting value or tuple or values (or None if no output)
pyuiua.Uiua() - Create a Uiua instance
uiua.push(value)- Push a Python value onto the stackuiua.pop()- Pop a value from the stack and return ituiua.run(code)- Execute Uiua code on the current stackuiua.stack()- Return all stack values as a list (without modifying)uiua.clear()- Remove all values from the stacklen(uiua)- Get the number of values on the stack
Type Conversions
The conversion of types is currently lossy. Both arrays and boxes convert to lists in Python, and Python lists convert to an array if they're homogeneous with a well-defined shape, otherwise a box. As a result, a box in Uiua of homogeneous values will become an array when converted to python and back.
- Currently supports: most scalars, multidimensional arrays, and boxed arrays
- Does not yet support: bytes, maps, functions, or user-defined types
Uiua → Python
| Uiua Type | Python Type |
|---|---|
| Scalar number | int or float |
| Scalar char | str |
| Scalar byte | int |
| 1D Array | list |
| Multi-dimensional Array | Nested list |
| Box Array (heterogeneous) | list |
Python → Uiua
| Python Type | Uiua Type |
|---|---|
int |
Scalar number |
float |
Scalar number |
str |
Character array/string |
list (homogeneous) |
Array |
list (heterogeneous) |
Box Array |
Development
Requirements
Set-up
# Clone
git clone https://github.com/KatieLG/python-uiua.git
cd python-uiua
# Install dependencies
uv sync
# Build and install
uv run maturin develop
Dev Commands
| Command | Purpose |
|---|---|
make dev |
Rebuild after making changes to Rust code |
make test |
Run unit tests |
make lint |
Run linters and type checkers |
make format |
Auto-format code |
make check |
Format, lint, and test |
make build |
Build wheel for distribution |
make test-release |
Publish to TestPyPI |
make release |
Publish to PyPI |
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyuiua-0.0.7.tar.gz.
File metadata
- Download URL: pyuiua-0.0.7.tar.gz
- Upload date:
- Size: 50.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413a4115fcd60371464718bd5133331d6d270a29347e95e536e44219a04e05ff
|
|
| MD5 |
9d3530da1ce86a90dd9a6b243d92b308
|
|
| BLAKE2b-256 |
96cde46fc223b81981d06de8efdfb8fdcdbe04b7a84dbeedbe0e3c447f8731b7
|
File details
Details for the file pyuiua-0.0.7-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: pyuiua-0.0.7-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 10.1 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e3a5854b5074207cffd89f6a2fcbc1695f331151cd231804ea2b29a67c30993
|
|
| MD5 |
5af3570b99fe818d26b70a975e540859
|
|
| BLAKE2b-256 |
a0a3cc55e00c9691832158e0d852b50b9265402d7214d65aee4b8ffe07f40fa1
|
File details
Details for the file pyuiua-0.0.7-cp310-abi3-win32.whl.
File metadata
- Download URL: pyuiua-0.0.7-cp310-abi3-win32.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb65d2fdcff5b25591ded48bb896094272fc8927016f40c3842e33407a99a2f
|
|
| MD5 |
a79575ddd6e34941960750f5f3a794a2
|
|
| BLAKE2b-256 |
8225929e08772a9c215510b1b1e05d3089877c407ac78a6cdacf3715e97c8b75
|
File details
Details for the file pyuiua-0.0.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyuiua-0.0.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.0 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
654f6d80be4d989b5dcbd59b645f79ebada9a59ceed3000a579468c1cff3b64b
|
|
| MD5 |
784469db7fe967796347964304f837af
|
|
| BLAKE2b-256 |
1998b7a569f4288d60af00b5ff44dd8f50ef9d5a318f322657bbb52cb1a19679
|
File details
Details for the file pyuiua-0.0.7-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyuiua-0.0.7-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e524f622c7edf3fde0a10105d9fd8d363fd92d0ef9720b04e59c311154dc022d
|
|
| MD5 |
f090019ef01497c4594210dd9291e805
|
|
| BLAKE2b-256 |
fa7acc37d4a02d55681479e3bc9bf23fbdafe21f8d0fe5607fd27990c1441115
|
File details
Details for the file pyuiua-0.0.7-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyuiua-0.0.7-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8ae05d6c77e38b27bb34af0dfa4a56481bff276a4b0ae10f1b2200bfd925e19
|
|
| MD5 |
f2386cd4f122630f229ad4c9d900e7f7
|
|
| BLAKE2b-256 |
35a68495d6fbd326a3fef73bca7cf3c62a08689bbdd7dbe1d2e49f6b0477d35c
|