-
Couldn't load subscription status.
- Fork 18
Modeling of Python functions in the SSA IR
Raffi Khatchadourian edited this page Nov 8, 2023
·
2 revisions
Consider the following Python function defined in file pretrain_paired_tf.py:
def get_num_samples(sample_md):
yml = read_yaml_tf(sample_md)
return yml['num_samples']The MethodReference corresponding to this function is:
< PythonLoader, Lscript pretrain_paired_tf.py/get_num_samples, do()LRoot; >
The TypeReference corresponding to this function is:
<PythonLoader,Lscript pretrain_paired_tf.py/get_num_samples>
Thus, it would seem that Python functions are modeled as objects and the "method" part of the MethodReference is a synthetic do(). This decision makes sense if you think of how functions are handled in Python; they are first-class entities (objects). From the above example, get_num_samples() is an instance of the "class" script pretrain_paired_tf.py/get_num_samples and the method that executes when get_num_samples() runs is d().