CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-wtfpython

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

Overall
score

93%

Overview
Eval results
Files

rubric.jsonevals/scenario-4/

{
  "context": "This evaluation assesses the engineer's understanding of Python's bytecode compilation and optimization mechanisms, specifically their ability to use the dis module to analyze constant folding and bytecode transformations.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "dis.dis() usage",
      "description": "Uses dis.dis() or dis.Bytecode() to disassemble code snippets and extract bytecode instructions",
      "max_score": 20
    },
    {
      "name": "compile() function",
      "description": "Uses compile() with appropriate mode ('eval' or 'exec') to convert code strings into code objects for bytecode analysis",
      "max_score": 15
    },
    {
      "name": "LOAD_CONST detection",
      "description": "Correctly identifies LOAD_CONST instructions in bytecode to detect when constant folding has occurred",
      "max_score": 20
    },
    {
      "name": "co_consts access",
      "description": "Accesses the co_consts attribute of code objects to extract optimized constant values after folding",
      "max_score": 15
    },
    {
      "name": "Instruction parsing",
      "description": "Properly parses bytecode instructions to extract opnames and arguments from dis.Bytecode or similar objects",
      "max_score": 15
    },
    {
      "name": "Folding detection logic",
      "description": "Implements correct logic to distinguish between folded constants (single LOAD_CONST) and non-folded operations (multiple instructions)",
      "max_score": 10
    },
    {
      "name": "Instruction counting",
      "description": "Accurately counts bytecode instructions to compare optimization levels across code variants",
      "max_score": 5
    }
  ]
}

Install with Tessl CLI

npx tessl i tessl/pypi-wtfpython

tile.json