fx-kirin / pyo3_decimal

C API Decimal class using PyO3, which can be imported from other pyo3 libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decimal implementation as User Custom C API using PyO3

pyo3_decimal for c extention python class as pyo3 library.

pyo3_decimal_api for rust side pyo3 API library to use pyo3_decimal.Decimal.

pyo3_decimal_user is an usage example.

use pyo3;
use pyo3::prelude::*;
use pyo3_decimal_api::PyDecimal;

#[pyfunction]
/// Formats the sum of two numbers as string
fn decimal_test(a: PyDecimal) -> PyResult<PyDecimal> {
    Ok(a)
}

/// This module is a python module implemented in Rust.
#[pymodule]
fn rust_binding(py: Python, m: &PyModule) -> PyResult<()> {
    m.add_wrapped(wrap_pyfunction!(decimal_test))?;

    Ok(())
}

Blog

PyO3 で rust-decimal を C API 化する

About

C API Decimal class using PyO3, which can be imported from other pyo3 libraries.


Languages

Language:Rust 70.9%Language:Python 29.1%