Created by: sneaxiy
This PR provides a gentle and common way to read C++ global variables in Python.
From now on, we can use fluid.core.globals()
as a dict to get the C++ variables by its name.
For example, when we read a C++ variable named X
, we can use:
x_value = fluid.core.globals()["X"]
When we write a C++ variable named X
, we can use:
fluid.core.globals()["X"] = some_other_value
Also support the following methods:
# find whether "value_name" exists
"value_name" in fluid.core.globals()
# return all variables names
fluid.core.globals().keys()
# return "X" value if "X" exists, while return default value if "X" does not exist
fluid.core.globals().get("X", default=False)