Skip to main content

星雀 xingque ✨🐦

GitHub Actions Workflow Status PyPI - License PyPI - Version Python Version from PEP 621 TOML PyPI - Implementation PyPI - Format PyPI - Downloads

Yet another Python binding to starlark-rust, exposing the Starlark language to your Python projects. The current version wraps starlark-rust version 0.12.x.

The project's name is a calque of "Starlark" into Chinese. It is pronounced xīng què (in Standard Pinyin) or Hsing-ch'üeh (in Wade-Giles).

The reason behind the curious name

I had to come up with another name for the project after discovering an identically named project after I first renamed the project starlark-pyo3 from python-starlark-rs, and that the probably next-best alternative pystarlark was also taken long ago. Fortunately though, the Chinese name is shorter to type, even shorter than "starlark" itself...

NOTE: this project still has rough corners, do not use in production yet without due care. Expect breaking changes to the API before a 1.0 version.

Features

A fair amount of starlark-rust API has been wrapped so far. You can see the smoke test cases for some examples on how to integrate this package.

This project as compared to other known bindings:

Feature ✨🐦 starlark-pyo3 starlark-go
License Apache-2.0 Apache-2.0 Apache-2.0
py.typed
Binding framework PyO3 PyO3 cgo
ABI3 compatibility ✅ any Python ≥ 3.8
Bundled ✨ Rust, 0.12.x Rust, 0.10.x Go, circa March 2023
Data marshalling ⚡ native FFI 📦 via Python json ⚡ native FFI
Accessing opaque 🐍 values from ✨ 💥 crashes
Accessing opaque ✨ values from 🐍
Magic method proxying for opaque 🐍 values ✅ somewhat complete
Magic method proxying for opaque ✨ values 🔧 WIP
Invoking 🐍 callables from ✨
Invoking ✨ callables from 🐍
Linting 📆 planned
LSP integration 📆 planned
Profiling & code coverage 📆 planned
Structured ✨ documentation 📆 planned

Objects across language boundary

Two-way data marshalling is done natively if a type is available both in Python and Starlark. For complex and/or user-defined types such as classes, opaque wrappers at both sides are available to allow some flexibility -- after all, people would expect some degree of interoperability between Python and Starlark, because Starlark is (arguably) seen by many as a dialect of Python. Opaque Python values in Starlark all have the pyobject type; while opaque Starlark values are starlark.FrozenValue and starlark.Value in Python.

Identity i.e. uniqueness for the underlying concrete objects is NOT preserved for objects across the language boundary: for example, each time you get a plain-old-data value from a FrozenModule a new Python object would be created. This should not cause problems at the Starlark side, as identity comparison (the is operator) is not supported in Starlark anyway, but you should take care at the Python side. Opaque Python values in Starlark context maintain their identities when being read back from Python though, because they are in fact just references to the original object being set.

xingque proxies an opaque Python value's most magic methods into Starlark. This means you can pass your Python objects and callables into Starlark, and use them largely as if the runtime is still Python.

Due to missing API in Starlark and/or PyO3, there can be some operators for whose Python to Starlark proxying is not supported right now. Currently this is:

  • absolute value: Starlark abs(x), Python __abs__: missing StarlarkValue trait method

There are other features that are not implemented right now, but I have plans to support in a future version. These are:

  • slicing i.e. sequence-like usage
  • __{get,set,del}item__ i.e. mapping-like usage
  • iterator protocol

Memory safety

There is no enforced ownership tracking in Python, unlike Rust, so exceptions will be thrown if one tries to use an already consumed object, for example an AstModule already evaluated by an Evaluator.

The starlark::values::Value type does not allow tracking its originating heap in the public API (at least during my investigation while implementing this library), so beware: Python interpreter crashes can occur if a starlark.Value's originating heap is GC-ed but a reference to such a Value is kept elsewhere and later used. More design is needed for fixing the problem; one should expect breaking changes to the API in a future version of this library. Meanwhile, use frozen values and modules whenever appropriate; more determinism can never hurt.

License

Copyright © 2024 WANG Xuerui. All rights reserved.

xingque is licensed under the Apache 2.0 license.

Release files for xingque 0.2.1

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

Source distribution (sdist)

Source distribution for xingque 0.2.1
File Size Uploaded
xingque-0.2.1.tar.gz 43.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for xingque 0.2.1
File
xingque-0.2.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
xingque-0.2.1-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details
xingque-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details
xingque-0.2.1-cp38-abi3-musllinux_1_2_i686.whl CPython 3.8 abi3 Linux musl 1.2+ x86-32 Details
xingque-0.2.1-cp38-abi3-musllinux_1_2_armv7l.whl CPython 3.8 abi3 Linux musl 1.2+ ARMv7l Details
xingque-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details
xingque-0.2.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
xingque-0.2.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.8 abi3 Linux glibc 2.17+ IBM System/390x Details
xingque-0.2.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.8 abi3 Linux glibc 2.17+ PowerPC 64-le Details
xingque-0.2.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.8 abi3 Linux glibc 2.17+ ARMv7l Details
xingque-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
xingque-0.2.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.8 abi3 Linux glibc 2.5+ x86-32 Details
xingque-0.2.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
xingque-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 48.3 MB

Release files / xingque-0.2.1.tar.gz

Download URL xingque-0.2.1.tar.gz
Size 43.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03fcd14b7d9e33f09abb27884b29dd0902b30dafc7710a1fdac83e23b2fbc395
BLAKE2b-256 checksum
How to use checksums
fb1d151efa987f1b3b081266ea673351110680be29159cd905d1bc3468dd5751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-win_amd64.whl

Download URL xingque-0.2.1-cp38-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6ad177e50311bd6f646c47882c314113e09ece4bcb9edd7bddf3bdeef30c82ff
BLAKE2b-256 checksum
How to use checksums
3cd8510275696bccaf7dc1cee0c23789bb2330b30a8ae32d86c890d0e1063b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-win32.whl

Download URL xingque-0.2.1-cp38-abi3-win32.whl
Size 2.3 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
a78f4fa5ff06109d3de2f9fb71b1ecfa8c3d0969995bb695ccdb98c7a2c59820
BLAKE2b-256 checksum
How to use checksums
2f711c63a15cc4ca2c7b3e5979fa75d37e3895537245ff57b0b115704ba28f0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL xingque-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
819f91c595c236113051f454ed4d20b48663cd79029d4ff6dd1dfc5f709d3116
BLAKE2b-256 checksum
How to use checksums
1b20790a3e32ad20101519f8f17ce500de5b2b1783b7e1cd5845057642a04026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-musllinux_1_2_i686.whl

Download URL xingque-0.2.1-cp38-abi3-musllinux_1_2_i686.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
73363c7245b0afcd0e027dc5b0fd3cfc9a67b9164ba86acb17c60cc9a24e41d5
BLAKE2b-256 checksum
How to use checksums
ee93f541c5f6792e8e8ab1248cddc0b92b9e05dfdac0ef7f9d035cded8827a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-musllinux_1_2_armv7l.whl

Download URL xingque-0.2.1-cp38-abi3-musllinux_1_2_armv7l.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
7834d0ca6e4c8e5d5328924de2b2c19f868b907097b7c16bb35ec118f65d6ddf
BLAKE2b-256 checksum
How to use checksums
43e7b1cb37066198b25a99a2d4e2ea85bcadadd47cec8a53125ed788ae7824fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL xingque-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
b5782ced27b412d83b6402dc7979e0d5fd19f149d031a067358f62a315704720
BLAKE2b-256 checksum
How to use checksums
8fb7ffeb0ec5a4646d7186fa124b17e06a615f90c9133793ff34defb27c13a27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7784d9bdf74585c776d0ceb2754fd5423983bd33a41493858c914693d334ce3e
BLAKE2b-256 checksum
How to use checksums
082f720be85647b820f11da6d3be1b34d1ecf77f93b804c21b034a177eff3b80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 4.2 MB
Tags CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
c6e0ec7dde4786f4a8085a61a271198b944bcc97ba0ac05f12cbd804f2a67fd8
BLAKE2b-256 checksum
How to use checksums
acad0665cb16f34e90d9b56a1998b19a6cc5f6cdd9b14c0bbd0933606a5798c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 3.8 MB
Tags CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
d4de66132e589135522bcc8254bbd6ccd5903e643de8005faf569b05d72698f1
BLAKE2b-256 checksum
How to use checksums
0b9e55de2663a4646b9f15af0c210394338fb08bd67920d4ff37323c2ee83c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 3.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
f431906a0f13a14bcbec7507490db910964219f4b01f712d742ebd5c483ebdaf
BLAKE2b-256 checksum
How to use checksums
65b6f06ae8350cc0df826fa6150b4da582f3129a865b7496321b643278120a38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0b02c4e9359b6c3a78e8d172cc5a3b78340a7cd35c0610577be3dd0b9a17f0cc
BLAKE2b-256 checksum
How to use checksums
94d9feb60be6a185bf44ebb41d1084c68b6200868073ee2b42fb3fa9ee815434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL xingque-0.2.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
9fb7eb0ed3d4cd2834852e91d3c935c03d5ba8a118fe09ee523f0bdcf905f6c3
BLAKE2b-256 checksum
How to use checksums
692f8c387fbd8ab8322835785107f08e4454d376b1f9e529007181fb81bde28d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL xingque-0.2.1-cp38-abi3-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0f51c06d9ab1d5e91950cb1c3cc9b413b2039ce38e79b059cbeba8e2b17399ab
BLAKE2b-256 checksum
How to use checksums
c5db251615ffa198b6655297ac6117e3784cdbba88777cdd9a65b10848970978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release files / xingque-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL xingque-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
c709b06b35965a5ebad76ffc550ffe7c11c6988d43f079cd0d2799789be117be
BLAKE2b-256 checksum
How to use checksums
4a0e70b5897e42608fb8be6b93f912f8901c81a7924eeb86f08bf0fc6691723a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.7.0

Release history Release notifications | RSS feed

This release

0.2.1 This release

15 release files

0.2.0

15 release files

0.1.0

15 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