class_docstr: Introspect UDF bytecode and determine if we can rewrite as native expression.
class_docstr_tok: ["Introspect","UDF","bytecode","and","determine","if","we","can","rewrite","as","native","expression","."]
docstr: Determine if we may be able to offer a native polars expression instead.
  
  Note that `lambda x: x` is inefficient, but we ignore it because it is not
  guaranteed that using the equivalent bare constant value will return the
  same output. (Hopefully nobody is writing lambdas like that anyway...)
code: def can_attempt_rewrite(self) -> bool:
      """
      Determine if we may be able to offer a native polars expression instead.
  
      Note that `lambda x: x` is inefficient, but we ignore it because it is not
      guaranteed that using the equivalent bare constant value will return the
      same output. (Hopefully nobody is writing lambdas like that anyway...)
      """
      return (
          self._param_name is not None
          # check minimum number of ops, ensuring all are parseable
          and len(self._rewritten_instructions) >= 2
          and all(
              inst.opname in OpNames.PARSEABLE_OPS
              for inst in self._rewritten_instructions
          )
          # exclude constructs/functions with multiple RETURN_VALUE ops
          and sum(
              1
              for inst in self.original_instructions
              if inst.opname == "RETURN_VALUE"
          )
          == 1
      )
  
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 6 for calling the BytecodeParser obj's underlying member method code with example usage: obj.can_attempt_rewrite() and returns: unknown