Skip to main content

Fluentmap

Testing Package version Python

Fluentmap provides a drop-in Python map replacement featuring parallel and batch processing.

Features

  • Use executor to run tasks in parallel.
  • Use batch_size/chunk_size to send parameters in batches/chunks.
  • Use num_prepare to prepare data in advance for better performance.
  • Call on_return hook to process the return value of each task.

Installation

Fluentmap requires Python 3.8 or newer, has no runtime dependencies, and is tested on CPython 3.8-3.15, including the free-threaded builds (3.13t-3.15t).

Fluentmap is available on PyPI:

pip install fluentmap

Usage

Drop-in replacement

You can start to use fluentmap just like built-in map:

from typing import Any, List

from fluentmap import map


items: List[str] = [...]


def heavy_task(item: str) -> Any:
    """Suppose this function represents a computationally expensive task."""


def postprocessing(result: Any):
    """Suppose this function represents a postprocessing task."""


for result in map(heavy_task, items):
    postprocessing(result)

Parallel processing

As heavy_task is a computationally expensive task, you can use executor to run it in parallel.

from concurrent.futures import ProcessPoolExecutor

from fluentmap import map

# ......

with ProcessPoolExecutor() as executor:
    # each heavy_task invocation runs in a separate process
    for result in map(heavy_task, items, executor=executor):
        postprocessing(result)

Batch/chunk processing

You can use batch_size/chunk_size to send arguments in batches/chunks.

The difference between them is that batch_size packs multiple arguments into a batch before sending them to the function, therefore the function needs to be modified to handle a list of arguments.

On the other hand, chunk_size packs multiple arguments into a chunks before passing them to executor workers, while workers still process each argument sequentially.

from concurrent.futures import ProcessPoolExecutor
from typing import Any, List

from fluentmap import map


# ......


def heavy_task_in_batch(item: List[str]) -> Any:
    """Note that `item` is a list since when `batch_size` is set,
    fluentmap will concatenate multiple items into a batch before sending them to
    the function which is to be invoked.
    """


# An example of using `batch_size`
with ProcessPoolExecutor() as executor:
    for result in map(
        heavy_task_in_batch,
        items,
        executor=executor,
        batch_size=64,
    ):
        postprocessing(result)

# An example of using `chunk_size` 
with ProcessPoolExecutor() as executor:
    for result in map(
        heavy_task,
        items,
        executor=executor,
        chunk_size=32,
    ):
        postprocessing(result)

Metadata

Release files for fluentmap 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fluentmap 0.1.1
File Size Uploaded Provenance
fluentmap-0.1.1.tar.gz 8.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fluentmap 0.1.1
File Interpreter ABI Platform
fluentmap-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / fluentmap-0.1.1.tar.gz

Download URL fluentmap-0.1.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e7b1a38bab4b083901ab93538c764025cee347fff9f6570fec08d93fbe4c01b5
BLAKE2b-256 checksum
How to use checksums
fee0763ebeb7ac4e796a4ba2b2752e23e8a7607fe9b8cb9036579fbeea718598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.3 CPython/3.14.8 Linux/6.17.0-1022-azure

Release files / fluentmap-0.1.1-py3-none-any.whl

Download URL fluentmap-0.1.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f271ed9d7d5205c88b55afc0f37f204fa7843cdd9ae5c40b32768103538a65d6
BLAKE2b-256 checksum
How to use checksums
fa80eebb6f204349adaad34a840fa0d4b3464ab29d0dfffce8431b29d858ab4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.3 CPython/3.14.8 Linux/6.17.0-1022-azure

Security for fluentmap 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page