Skip to content
Pyrula

Numeric Lists

IntList and FloatList are specialized lists for numbers. The math runs in Rust, so scalar ops, reductions, and pairwise math happen without a Python-level loop. Use them when you’re crunching numbers and a regular IList of boxed ints is the bottleneck.

from pyrula import IntList
xs = IntList([1, 2, 3, 4])
xs.mul_scalar(10) # IntList([10, 20, 30, 40])
xs.clamp_vals(2, 3) # IntList([2, 2, 3, 3])
xs.sum() # 10
xs.mean() # 2.5
xs.std_dev() # population std dev

Scalar ops (add_scalar, sub_scalar, mul_scalar, div_scalar), abs_vals, and clamp_vals each return a new list. Reductions (sum, min, max, mean, std_dev) return a number.

Pairwise math takes another list of the same type:

a = IntList([1, 2, 3])
b = IntList([10, 20, 30])
a.zip_add(b) # IntList([11, 22, 33])
a.zip_mul(b) # IntList([10, 40, 90])

FloatList has the same surface with float scalars and map_float. Both convert with to_list (plain Python list) and to_ilist (a general IList) when you need to leave the numeric fast path.

BytesList is the same idea for bytes: a tight, append-only list used on the serialization and Kafka paths. It carries get, append, to_list, and to_ilist.