or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/asyncstdlib@3.13.x
tile.json

tessl/pypi-asyncstdlib

tessl install tessl/pypi-asyncstdlib@3.13.0

The missing async toolbox - re-implements functions and classes of the Python standard library to make them compatible with async callables, iterables and context managers

Agent Success

Agent success rate when using this tile

84%

Improvement

Agent success rate improvement when using this tile compared to baseline

3.36x

Baseline

Agent success rate without this tile

25%

task.mdevals/scenario-10/

Data Analytics Metrics Calculator

Build a data analytics system that computes expensive metrics from datasets with proper caching to avoid redundant calculations.

Requirements

Create a MetricsCalculator class that:

  1. Accepts a dataset (list of numbers) upon initialization
  2. Provides three computed metrics as async properties:
    • mean: The average value of the dataset
    • variance: The variance of the dataset
    • std_dev: The standard deviation of the dataset
  3. Each metric computation should include a small async delay (e.g., 0.1 seconds) to simulate an expensive operation
  4. Each metric should be computed only once and cached for subsequent accesses
  5. When multiple coroutines access an uncached property concurrently, the computation should happen only once
  6. Cached values can be invalidated using del (e.g., del calculator.mean), after which the next access recomputes the value

Implementation

@generates

API

class MetricsCalculator:
    """
    A class that computes statistical metrics from a dataset with caching.
    """

    def __init__(self, data: list[float]):
        """
        Initialize the calculator with a dataset.

        Args:
            data: A list of numeric values to analyze
        """
        pass

    async def mean(self) -> float:
        """
        Calculate and cache the mean of the dataset.

        Returns:
            The mean (average) value
        """
        pass

    async def variance(self) -> float:
        """
        Calculate and cache the variance of the dataset.

        Returns:
            The variance value
        """
        pass

    async def std_dev(self) -> float:
        """
        Calculate and cache the standard deviation of the dataset.

        Returns:
            The standard deviation value
        """
        pass

Test Cases

  • The mean property returns the correct average value for a given dataset @test
  • The variance property returns the correct variance value for a given dataset @test
  • The std_dev property returns the correct standard deviation value for a given dataset @test
  • Accessing the same property multiple times returns cached results without recomputation @test
  • Concurrent access to the same uncached property computes the value only once @test
  • Deleting a cached property and accessing it again triggers recomputation @test

Dependencies { .dependencies }

asyncstdlib { .dependency }

Provides async-compatible standard library functions including cached property support.