Skip to main content

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 stack
  • uiua.pop() - Pop a value from the stack and return it
  • uiua.run(code) - Execute Uiua code on the current stack
  • uiua.stack() - Return all stack values as a list (without modifying)
  • uiua.clear() - Remove all values from the stack
  • len(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: 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

  • rustup (Rust installer)
  • uv (Python package manager)

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

Metadata

Release files for pyuiua 0.0.9

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

Source distribution (sdist)

Source distribution for pyuiua 0.0.9
File Size Uploaded
pyuiua-0.0.9.tar.gz 50.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyuiua 0.0.9
File
pyuiua-0.0.9-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pyuiua-0.0.9-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details
pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 49.8 MB

Release files / pyuiua-0.0.9.tar.gz

Download URL pyuiua-0.0.9.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f7f9b8f48197ae916bfb4370ec441280b45a14b2aa7904110be1306f2993ee89
BLAKE2b-256 checksum
How to use checksums
3c88e28467f04994978589cfd553c34e3c63066c5e0f207f1b5282003be01db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release files / pyuiua-0.0.9-cp310-abi3-win_amd64.whl

Download URL pyuiua-0.0.9-cp310-abi3-win_amd64.whl
Size 10.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6347f571399c6249d2621cd1387076185b47c150863c24239d328f11960c47db
BLAKE2b-256 checksum
How to use checksums
979f0fe56ef0ba2e17949892890bfdb8fee03b4a449022460682293d807e8cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release files / pyuiua-0.0.9-cp310-abi3-win32.whl

Download URL pyuiua-0.0.9-cp310-abi3-win32.whl
Size 8.8 MB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
764c2ae4733c397a0846aa4c3631d35ac2ad8b305556f1305166611c09e8cf68
BLAKE2b-256 checksum
How to use checksums
db9ec1a25b503f646984e57420f9776c5c74a54c8592e04d27f9b67193215d6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release files / pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 11.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2dbb9cba1e93ce6257df4549f9df2507c02ca66359e6d52c449bda03e9858abb
BLAKE2b-256 checksum
How to use checksums
0e2639a3b3a5d39bfbfc3c67069815e19bb0aad8d71443612abc31701d59af98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release files / pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl

Download URL pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl
Size 9.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
df4f9569cf71c77ab6751a31d9a1f86d96ad0eed3f7f47d414d50abf6ba645db
BLAKE2b-256 checksum
How to use checksums
39d571030ba487d628e68d5cc13eff44918f6a9ef4db9a1a215fc4a2368fdba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release files / pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl
Size 10.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7292e245751221699b8781e71f28d6cd9fc1910fc07f18f843b26c2964fabfc2
BLAKE2b-256 checksum
How to use checksums
1c7c007f763b95b1d66c3e31ccdd66f9970705e4866efa667640c4a44c0de800
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.10.2

Release history Release notifications | RSS feed

This release

0.0.9 This release

6 release files

0.0.8

6 release files

0.0.7

6 release files

0.0.6

6 release files

0.0.5

6 release files

0.0.4

20 release files

0.0.3

20 release files

0.0.2

20 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