RELEASE V1.0.0

Rolling window statistics for numpy arrays.
No pandas needed.

A lightweight, zero-dependency Python library for calculating fast, vectorized rolling-window statistics on 1D NumPy arrays. Built safely using memory-efficient NumPy stride tricks for instant calculations with zero memory copies.

> pip install rollit
Get StartedStar on GitHub
Vectorized calculations Zero-copy strides
rollit logo showcase
WHY ROLLIT?

The weight of Pandas. The speed of C.

Data analysis tasks often import Pandas simply to compute a rolling average or standard deviation. However, Pandas brings a heavy 35 MB+ installation size, high memory overhead, and requires converting your clean NumPy arrays to DataFrames and back.

Available on PyPI, `rollit` is a zero-dependency Python package. It runs rolling statistics directly on 1D NumPy arrays at C-speed using memory strides, giving you instant vectorized results without any external bloat.

Quick Code Example
import numpy as np
import rollit

# 1D array of data (price feeds, sensor streams)
data = np.array([10.0, 20.0, 15.0, 30.0, 25.0])

# Vectorized rolling mean (window size = 3)
averages = rollit.mean(data, window=3)
print(averages)
# Output: [15.0, 21.67, 23.33]
* Note: rollit is built specifically for 1D NumPy arrays to maximize stride efficiency.

Core Value Propositions

`rollit` provides a secure, lightweight utility designed specifically for calculation-heavy data feeds and time-series arrays.

Zero Dependencies

Calculated entirely using pure NumPy views. Avoid a heavy 35 MB pandas import just to run a single rolling-window calculation.

Segfault-Safe Memory

Direct memory modification via `as_strided` is highly dangerous. rollit bounds-checks window sizes and locks returned array flags as read-only.

Unified Simple API

One clean pattern `rollit.mean(arr, window)` across all functions, making it a drop-in replacement for pandas statistics.

Out-of-the-Box Math

Built-in rolling Z-Scores for anomaly detection, local Min-Max Normalization scaling, and custom function escape hatches.

Window Calculations

Visualize how statistics are computed as the rolling window slides across your inputs.

Control Panel

W=2W=3W=4W=5
Input Array (Length: 7)
[0]10
[1]20
[2]15
[3]30
[4]25
[5]40
[6]10
Slide:
Window Step: 1/5
Formula Execution
Mean:
μ =
1W
∑ xi
(10 + 20 + 15) / 3 = 15.00
Output Array (Length: 5)
[0]15.0
[1]-
[2]-
[3]-
[4]-

How It Works: Zero-Copy Strides

`rollit` avoids making memory copies by re-interpreting array byte steps.

NumPy Stride Tricks

Normally, calculating rolling statistics requires copying slices of the array into new memory blocks. This is slow and doubles memory usage.

rollit uses NumPy's native stride manipulation. By setting custom strides (the number of bytes to skip in memory to find the next element), it creates a 2D view pointing to the exact same 1D array blocks in physical memory.

Interaction: Hover or tap over the 2D rows in the right panel to highlight the corresponding window offset in the physical 1D array.
Physical 1D Array in RAM (Float64)Stride: (8,) bytes
idx 010x00
idx 120x08
idx 230x10
idx 340x18
idx 450x20
Reshaped 2D Memory View (3x3)Strides: (8, 8) bytes
Row 0
1
2
3
Row 1
2
3
4
Row 2
3
4
5

Performance Benchmarks

Move the slider to adjust array size and compare real-world calculation times.

Controls

10K elements1M elements
Verdict

For 500K elements, rollit finishes in 2.50 ms, outperforming Python loops by 100x.

Pandas requires a 35 MB import footprint and converts views to DataFrames.

Execution Time Comparison (Lower is Better)

Python Loop250.0 ms
Pandas (.rolling())38.0 ms
rollit 2.50 ms
* Timings include calculations for window W=30. Pandas timing includes import start latency.