or run

tessl search
Log in

Version

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

tessl/pypi-fastcore

tessl install tessl/pypi-fastcore@1.8.0

Python supercharged for fastai development

Agent Success

Agent success rate when using this tile

56%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.37x

Baseline

Agent success rate without this tile

41%

task.mdevals/scenario-7/

Function Wrapper Utilities

Build utilities for wrapping functions to modify their behavior and signatures.

Requirements

Implement two function wrappers:

  1. Auto-starting generator wrapper: Wrap generator functions so they automatically advance to the first yield statement when created, making them immediately ready to receive values via send().

  2. Signature modifier: Create a decorator that hides the first N parameters from a function's visible signature while still allowing the function to receive those parameters at runtime.

Use Cases

Use Case 1: Auto-starting Generators

Generator functions normally require calling next() or send() before they can receive values. For coroutine-style generators, you want them ready to receive values immediately.

Example behavior:

# Without auto-start, this fails
gen = my_generator()
gen.send(value)  # Error: can't send to just-started generator

# With auto-start, this works
gen = auto_started_generator()
gen.send(value)  # Works immediately

Use Case 2: Hiding Internal Parameters

When creating wrapper functions or decorators, you often want to hide internal parameters from the visible signature while still accepting them at runtime.

Example behavior:

# Original function signature: func(internal_param, user_param)
# Wrapped function signature should appear as: func(user_param)
# But wrapped function should still accept both parameters when called

Implementation

Create a module generator_utils.py with these functions:

  1. make_autostart(generator_func) - Wraps a generator function to auto-start it
  2. hide_params(n) - Returns a decorator that hides the first n parameters from the signature

Test Cases

  • Auto-starting a generator function allows immediate sending of values @test
  • Auto-starting advances the generator to the first yield statement @test
  • Hiding 1 parameter removes it from the function signature @test
  • Hiding 2 parameters removes both from the function signature @test

Dependencies { .dependencies }

fastcore { .dependency }

Provides advanced function wrapping utilities.

@generates

API

def make_autostart(generator_func):
    """
    Wraps a generator function to automatically start it.

    Args:
        generator_func: A generator function to wrap

    Returns:
        A wrapper function that returns auto-started generators
    """
    pass

def hide_params(n):
    """
    Creates a decorator that hides the first n parameters from a function's signature.

    Args:
        n: Number of parameters to hide from the beginning

    Returns:
        A decorator function
    """
    pass