CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-asyncstdlib

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

84

3.36x

Quality

Pending

Does it follow best practices?

Impact

84%

3.36x

Average score across 10 eval scenarios

Overview
Eval results
Files

task.mdevals/scenario-6/

Async Data Filter Service

Build a service that processes async data streams by filtering elements based on corresponding boolean conditions.

Requirements

Your service should handle filtering of async data streams where each data element has a corresponding boolean selector that determines whether to include it in the output.

Core Functionality

Implement a function filter_by_selectors(data_stream, selector_stream) that:

  • Takes two async iterables as input: a data stream and a selector stream
  • Returns an async iterable containing only the data elements where the corresponding selector is truthy
  • Processes both streams in parallel
  • Stops when either stream is exhausted

Test Cases

  • When given data [1, 2, 3, 4, 5] and selectors [True, False, True, False, True], the output should be [1, 3, 5] @test
  • When given data ['a', 'b', 'c'] and selectors [False, False, False], the output should be an empty list @test
  • When given data ['x', 'y', 'z'] and selectors [True, True, True], the output should be ['x', 'y', 'z'] @test

Implementation

@generates

API

async def filter_by_selectors(data_stream, selector_stream):
    """
    Filter elements from data_stream based on corresponding selectors.

    Args:
        data_stream: An async iterable of data elements
        selector_stream: An async iterable of boolean selectors

    Returns:
        An async iterable yielding only elements where selector is truthy
    """
    pass

Dependencies { .dependencies }

asyncstdlib { .dependency }

Provides async-compatible standard library functions for working with async iterables.

Install with Tessl CLI

npx tessl i tessl/pypi-asyncstdlib

tile.json