or run

tessl search
Log in

Version

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

tessl/pypi-wtfpython

tessl install tessl/pypi-wtfpython@3.0.0

Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals

Agent Success

Agent success rate when using this tile

93%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.06x

Baseline

Agent success rate without this tile

88%

task.mdevals/scenario-7/

String Identity Analyzer

A utility that helps developers understand Python's string identity behavior and the difference between identity (is) and equality (==) checks.

Capabilities

Predict string interning

Implement a function that determines whether a string will be interned by CPython based on its characteristics.

  • A string literal "hello" returns True indicating it will be interned @test
  • A string literal "this is a very long string that exceeds the limit" returns False indicating it will not be interned @test
  • A string "hello world" with spaces returns False indicating it will not be interned @test

Compare identity and equality

Implement a function that compares two strings using both identity (is) and equality (==) operators and returns the results.

  • Comparing "test" (literal) with "test" (literal) returns both equal and identical @test
  • Comparing "test" (literal) with "te" + "st" (runtime) returns equal but not identical @test

Implementation

@generates

API

def will_be_interned(string_value: str) -> bool:
    """
    Determines if a string will be interned by CPython based on its characteristics.

    Args:
        string_value: The string to check

    Returns:
        True if the string will be interned, False otherwise
    """
    pass

def compare_strings(str1: str, str2: str) -> dict:
    """
    Compares two strings using both identity (is) and equality (==) operators.

    Args:
        str1: First string to compare
        str2: Second string to compare

    Returns:
        A dictionary with keys 'equal' (bool) and 'identical' (bool)
    """
    pass

Dependencies { .dependencies }

wtfpython { .dependency }

Educational resource explaining Python's string interning and identity behavior.

@satisfied-by