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.

Inline::Python3 v0.0.1

Python 3 integration for Raku

Authors

  • Danslav Slavenskoj

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Inline::Python3
  • Inline::Python3::BatchConvert
  • Inline::Python3::Cache::Integer
  • Inline::Python3::Cache::Method
  • Inline::Python3::Cache::String
  • Inline::Python3::Config
  • Inline::Python3::Installer
  • Inline::Python3::NumPy
  • Inline::Python3::Performance
  • Inline::Python3::Performance::Monitor

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.