class_docstr: Standalone class that applies Instruction rewrite/filtering rules.
  
  This significantly simplifies subsequent parsing by injecting
  synthetic POLARS_EXPRESSION ops into the Instruction stream for
  easy identification/translation and separates the parsing logic
  from the identification of expression translation opportunities.
class_docstr_tok: ["Standalone","class","that","applies","Instruction","rewrite\/filtering","rules",".","This","significantly","simplifies","subsequent","parsing","by","injecting","synthetic","POLARS_EXPRESSION","ops","into","the","Instruction","stream","for","easy","identification\/translation","and","separates","the","parsing","logic","from","the","identification","of","expression","translation","opportunities","."]
docstr: Replace builtin function calls with a synthetic POLARS_EXPRESSION op.
code: def _rewrite_builtins(
      self, idx: int, updated_instructions: list[Instruction]
  ) -> int:
      """Replace builtin function calls with a synthetic POLARS_EXPRESSION op."""
      if matching_instructions := self._matches(
          idx,
          opnames=[
              {"LOAD_GLOBAL"},
              {"LOAD_FAST", "LOAD_CONST"},
              OpNames.CALL,
          ],
          argvals=[_PYTHON_BUILTINS],
      ):
          inst1, inst2 = matching_instructions[:2]
          if (argval := inst1.argval) in _PYTHON_CASTS_MAP:
              dtype = _PYTHON_CASTS_MAP[argval]
              argval = f"cast(pl.{dtype})"
  
          synthetic_call = inst1._replace(
              opname="POLARS_EXPRESSION",
              argval=argval,
              argrepr=argval,
              offset=inst2.offset,
          )
          # POLARS_EXPRESSION is mapped as a unary op, so switch instruction order
          operand = inst2._replace(offset=inst1.offset)
          updated_instructions.extend((operand, synthetic_call))
  
      return len(matching_instructions)
  
imports: from __future__ import annotations
  import datetime
  import dis
  import inspect
  import re
  import sys
  import warnings
  from bisect import bisect_left
  from collections import defaultdict
  from dis import get_instructions
  from inspect import signature
  from itertools import count, zip_longest
  from pathlib import Path
  from typing import TYPE_CHECKING, AbstractSet, Any, Callable, ClassVar, Iterator, Literal, NamedTuple, Union
label_desc: Use image node_id 7 for calling the RewrittenInstructions obj's underlying member method code with example usage: obj._rewrite_builtins(idx, updated_instructions) and returns: len