MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _init_closure

Method _init_closure

lib/sqlalchemy/sql/lambdas.py:819–852  ·  view source on GitHub ↗
(self, fn)

Source from the content-addressed store, hash-verified

817 )
818
819 def _init_closure(self, fn):
820 build_py_wrappers = self.build_py_wrappers
821 closure = fn.__closure__
822
823 track_bound_values = self.track_bound_values
824 track_closure_variables = self.track_closure_variables
825 bindparam_trackers = self.bindparam_trackers
826 closure_trackers = self.closure_trackers
827
828 for closure_index, (fv, cell) in enumerate(
829 zip(fn.__code__.co_freevars, closure)
830 ):
831 _bound_value = self._roll_down_to_literal(cell.cell_contents)
832
833 if coercions._deep_is_literal(_bound_value):
834 build_py_wrappers.append((fv, closure_index))
835 if track_bound_values:
836 bindparam_trackers.append(
837 self._bound_parameter_getter_func_closure(
838 fv, closure_index
839 )
840 )
841 else:
842 # for normal cell contents, add them to a list that
843 # we can compare later when we get new lambdas. if
844 # any identities have changed, then we will
845 # recalculate the whole lambda and run it again.
846
847 if track_closure_variables:
848 closure_trackers.append(
849 self._cache_key_getter_closure_variable(
850 fn, fv, closure_index, cell.cell_contents
851 )
852 )
853
854 def _setup_additional_closure_trackers(self, fn, lambda_element, opts):
855 # an additional step is to actually run the function, then

Callers 1

__init__Method · 0.95

Tested by

no test coverage detected