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

Basic Usage

import pyuiua

# Create a Uiua instance
uiua = pyuiua.Uiua()

# Basic evaluation - run code and pop result
uiua.run("/×⇡₁10") # Calculate 10 factorial
print(uiua.pop())  # 3628800

# Push Python values onto the stack
uiua.push(10)
uiua.push(20)
uiua.run("+") # Then run a Uiua operation
print(uiua.pop())  # 30

# Work with arrays
uiua.push([1, 2, 3, 4, 5])
uiua.run("/+")  # Sum the array
print(uiua.pop())  # 15

# Inspect the stack without modifying it
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

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 as a python object
  • uiua.run(code) - Execute Uiua code on the current stack
  • uiua.stack() - Inspect the stack without modifying it
  • 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: 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

  • 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.6.tar.gz (49.5 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.6-cp310-abi3-win_amd64.whl (10.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+Windows x86

pyuiua-0.0.6-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.6-cp310-abi3-macosx_11_0_arm64.whl (9.5 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pyuiua-0.0.6-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.6.tar.gz.

File metadata

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

File hashes

Hashes for pyuiua-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1da59126133aafd06bd5d11e1ccccef2029ec0664f65e62e109d4cc6b4360c0f
MD5 85e74297cfb1cfac03018b7f0f9f29e0
BLAKE2b-256 4faf1deb4ac9f3898f1fc88d5848face27da3c537cfffdcdc419cd9618db8ca5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyuiua-0.0.6-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.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9b343c40bdffb797a4e73b8e45da61eb14f3fcb583d603e4241c1ac40e51c66a
MD5 0c1e0c2e973de48f9b1cb92b1781b968
BLAKE2b-256 3c7e9fae01c1c5b410e94014110cd58036a53a0af8886dc5a83200b015bb8514

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyuiua-0.0.6-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.6-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 c23633051cb74b8ffa570c0e0b477917869169f2c31626cd9035fc2dce7e4995
MD5 0280b1dc41c9948b2bc2affdba578899
BLAKE2b-256 98824c9ca16e56bb7207f3eb82abb352741140475aeb1efe4efcb7107394876c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyuiua-0.0.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97930d1e436962f1c1dd8a1ed10c1660163ffe1d4de1f97fb378ddebb8e9b8ba
MD5 311c43fd1bca302edc1e96af76253bc0
BLAKE2b-256 67e9749cc5f90bedcc879038c319b4d8f560115743a9df4e14917d03e7523c30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyuiua-0.0.6-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f67b5b447ba597c05191abd5083acc265d7ef02c039004a70bb83dfd07a3bee
MD5 fe019cbc387b76417bceafb0ef5a5749
BLAKE2b-256 8e786cf1d8d3c45c6d6347e3d36672d364f917086233d8831744e4902f0b2e92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyuiua-0.0.6-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ef8adacfcf3125f53316391722af9fa2486219b05313e03d7ffdbc5ef0f8efb7
MD5 6dd77d96cf852ebd7939d180bb7c9556
BLAKE2b-256 cc32d78824ef4338b561a82ebbfdfbaa385911e6c8a3196d2ea3bf6101dbcdea

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