Skip to content

Instantly share code, notes, and snippets.

@PaluMacil
Created March 24, 2026 00:34
Show Gist options
  • Select an option

  • Save PaluMacil/d976ec16b65442ff34e888bfaca38082 to your computer and use it in GitHub Desktop.

Select an option

Save PaluMacil/d976ec16b65442ff34e888bfaca38082 to your computer and use it in GitHub Desktop.
xingque isn't actively updated, but it has fantastic capability to call back into Python code from the Starlark code
from xingque import AstModule, GlobalsBuilder, Evaluator
def foo():
return 88
def main():
text = """
def square(x):
return x * x
a = 42
b = square(a)
z = b + 1 + int(bool(233))
foo()
"""
ast = AstModule.parse("test.star", text)
gb = GlobalsBuilder.standard()
gb.set("foo", foo)
g = gb.build()
e = Evaluator()
result = e.eval_module(ast, g)
print(type(result))
print(result)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment