guides

Working with NumPy and Pandas

Best practices for compiling code that uses NumPy, Pandas, and SciPy.

Published May 30, 2026

NumPy Best Practices

Pyvorin compiles the Python orchestration code around NumPy calls. The NumPy C operations themselves already run at native speed.

import numpy as np

def process(arr):
    result = []
    for i in range(len(arr)):
        val = arr[i] * 2 + 1
        result.append(val)
    return np.array(result)

The Python loop above will be compiled natively; the np.array call falls back to CPython gracefully.

Pandas DataFrames

DataFrame operations inside loops can benefit from compilation:

def transform_rows(df):
    results = []
    for idx, row in df.iterrows():
        results.append(row['price'] * row['quantity'])
    return results

SciPy

SciPy functions are C-backed and do not need compilation. Focus Pyvorin on the Python glue code that calls SciPy.

Interop Limitations

  • Direct mutation of NumPy C arrays from compiled code is unsupported.
  • Pandas ExtensionArrays may fall back to CPython.
  • Numba-jitted functions cannot be further compiled by Pyvorin.