Crate benda

Source
Expand description

Benda Module

This module provides functionality for working with Bend code, including loading and parsing Bend books, and compiling Python functions to Bend code at runtime.

The module includes functions for loading Bend books from strings or files, as well as the PyBjit class, which serves as an annotation for compiling Python functions to Bend code.

§Key Components

  • load_book: Load a Bend book from a string of Bend code
  • load_book_from_file: Load a Bend book from a file
  • PyBjit: Annotation class for compiling Python functions to Bend code at runtime

§Examples

from benda import bjit, load_book

# Load a Bend book from a string
book = load_book("some bend code here")

# Use the bjit annotation to compile a Python function to Bend code
@bjit
def add(x, y):
    return x + y

result = add(1, 2)  # This will execute the Bend-compiled version of the function
print(result)  # Output: 3

# Load a Bend book from a file
book_from_file = load_book_from_file("/path/to/bend/file.bend")

§Note

This module integrates Python and Bend, allowing for seamless interaction between the two languages. It’s particularly useful for projects that need to leverage Bend’s capabilities while working within a Python environment.

Modules§

benda_ffi
Bend Interface Module
types

Structs§

PyBjit
Bjit decorator

Functions§

load_book
Load a Book from a string of Bend code
load_book_from_file
Load a Book from a file