BatchConvert
NAME
Inline::Python3::BatchConvert - Efficient batch conversions between Raku and Python
SYNOPSIS
use Inline::Python3;
use Inline::Python3::BatchConvert;
my $py = Inline::Python3.new;
# Convert large array efficiently
my @data = 1..1000000;
my $py-list = $py.batch-to-python(@data); # Much faster than element-wise
# Convert back
my @result = $py.batch-from-python($py-list);
# Works with mixed types too
my @mixed = 1, "hello", 3.14, True;
my $py-mixed = $py.batch-to-python(@mixed);
# Dictionaries
my %hash = a => 1, b => 2, c => 3;
my $py-dict = $py.batch-dict-to-python(%hash);
DESCRIPTION
This module provides optimized batch conversion operations between Raku and Python. It dramatically improves performance when converting large collections.
Optimizations
Homogeneous type detection and specialized conversion
Batch memory allocation
Minimal Python API calls
SIMD operations where available
Chunked processing for huge datasets
Performance
Batch conversions are typically 10-100x faster than element-wise conversion: - 1M integers: ~50ms vs ~5s - 1M strings: ~200ms vs ~10s - Mixed types: ~500ms vs ~8s
METHODS
batch-to-python(@values)
Convert Raku array to Python list using batch operations.
batch-from-python($py-list)
Convert Python list to Raku array using batch operations.
batch-dict-to-python(%hash)
Convert Raku hash to Python dict efficiently.
batch-dict-from-python($py-dict)
Convert Python dict to Raku hash efficiently.