Example 2 – PyCall.jl package

The PyCall.jl package's documentation suggests the user stores a Python object using the global variable placeholder technique. The following excerpt can be found in its documentation:

"For a type-stable global constant, initialize the constant to PyNULL() at the top level, and then use the copy! function in your module's __init__ function to mutate it to its actual value."

A type-stable global constant is generally what we want for high-performance code. Basically, when the module is initialized, this global constant can be initialized with a value of PyNULL(). This constant is really just a placeholder object that can be mutated with the actual value later.

This technique is similar to the use of Ref as mentioned in the Hiding a variable inside a global constant section. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.150.89