Skip to main content

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 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

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyuiua-0.0.9.tar.gz (50.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyuiua-0.0.9-cp310-abi3-win_amd64.whl (10.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

pyuiua-0.0.9-cp310-abi3-win32.whl (8.8 MB view details)

Uploaded CPython 3.10+Windows x86

pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl (9.5 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file pyuiua-0.0.9.tar.gz.

File metadata

  • Download URL: pyuiua-0.0.9.tar.gz
  • Upload date:
  • Size: 50.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for pyuiua-0.0.9.tar.gz
Algorithm Hash digest
SHA256 f7f9b8f48197ae916bfb4370ec441280b45a14b2aa7904110be1306f2993ee89
MD5 8345b33a07498ed79066fb002f26912f
BLAKE2b-256 3c88e28467f04994978589cfd553c34e3c63066c5e0f207f1b5282003be01db2

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.9-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pyuiua-0.0.9-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

Hashes for pyuiua-0.0.9-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6347f571399c6249d2621cd1387076185b47c150863c24239d328f11960c47db
MD5 923f61d34a777754a3f7e9cdbf6ccb78
BLAKE2b-256 979f0fe56ef0ba2e17949892890bfdb8fee03b4a449022460682293d807e8cfd

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.9-cp310-abi3-win32.whl.

File metadata

  • Download URL: pyuiua-0.0.9-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

Hashes for pyuiua-0.0.9-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 764c2ae4733c397a0846aa4c3631d35ac2ad8b305556f1305166611c09e8cf68
MD5 414410f2978f02cdc8580319beee90e4
BLAKE2b-256 db9ec1a25b503f646984e57420f9776c5c74a54c8592e04d27f9b67193215d6c

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2dbb9cba1e93ce6257df4549f9df2507c02ca66359e6d52c449bda03e9858abb
MD5 905b33c680268820c436d939dc7afe6d
BLAKE2b-256 0e2639a3b3a5d39bfbfc3c67069815e19bb0aad8d71443612abc31701d59af98

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.9-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df4f9569cf71c77ab6751a31d9a1f86d96ad0eed3f7f47d414d50abf6ba645db
MD5 3a0cc6647f40e50f83691c28c6a0e2c1
BLAKE2b-256 39d571030ba487d628e68d5cc13eff44918f6a9ef4db9a1a215fc4a2368fdba3

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.9-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7292e245751221699b8781e71f28d6cd9fc1910fc07f18f843b26c2964fabfc2
MD5 3de1edae89d388f1d31c3c3f55e9fd2e
BLAKE2b-256 1c7c007f763b95b1d66c3e31ccdd66f9970705e4866efa667640c4a44c0de800

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page