|
| aliasDefinition (string python_source_path, string python_target_path) |
| Creates an alias in the Python program for the given symbol. More...
|
|
auto | callFunction (string func_name,...) |
| Call the given function and return the result. More...
|
|
auto | callFunctionArgs (string func_name, *softlist< auto > argv) |
| Call the given function and return the result. More...
|
|
auto | callMethod (string class_name, string method_name,...) |
| Call the given method and return the result. More...
|
|
auto | callMethodArgs (string class_name, string method_name, *softlist< auto > argv) |
| Call the given method and return the result. More...
|
|
| constructor (string source_code, string source_label) |
| Creates the object and parses and runs the given source code. More...
|
|
| destructor () |
| Destroys the interpreter context and invalidates the object.
|
|
auto | evalExpression (string source_code, string source_label="exp") |
| Parse, compile, and evaluate the given expression and return any result. More...
|
|
auto | evalStatement (string source_code, string source_label="stmt") |
| Parse, compile, and evaluate the given statement and return any result; declarations are not persistent. More...
|
|
auto | evalStatementKeep (string source_code, string source_label="stmt") |
| Parse, compile, and evaluate the given statement and return any result; declarations are persistent. More...
|
|
| importNamespace (string qore_ns_path, string py_module_path) |
| Imports the given Qore namespace to the Python program object under the given module path. More...
|
|
auto | run () |
| Runs the program. More...
|
|
| setSaveObjectCallback (*code save_object_callback) |
| Sets the "save object" callback for Qore objects created from Python code. More...
|
|
|
static auto | evalExpression (string source_code, string source_label="exp") |
| Parse, compile, and evaluate the given expression and return any result. More...
|
|
static auto | evalStatement (string source_code, string source_label="stmt") |
| Parse, compile, and evaluate one or more Python statements and return any result. More...
|
|
static auto | evalStatementKeep (string source_code, string source_label="stmt") |
| Parse, compile, and evaluate the given code and leave declarations in the Python program object. More...
|
|
static | setSaveObjectCallback (*code save_object_callback) |
| Sets the "save object" callback for Qore objects created from Python code in the root Qore Program context. More...
|
|
Program for embedding and executing Python code.
- Restrictions:
- Qore::PO_NO_EMBEDDED_LOGIC
Python::PythonProgram::setSaveObjectCallback |
( |
*code |
save_object_callback | ) |
|
Sets the "save object" callback for Qore objects created from Python code.
- Restrictions:
- Qore::PO_NO_PROCESS_CONTROL
- Example:
hash<string, object> object_cache;
code callback = sub (object obj) {
object_cache{obj.uniqueHash()} = obj;
}
pypgm.setSaveObjectCallback(callback);
- Parameters
-
save_object_callback | the callback to save any Qore objects created in Python code, must take an argument of type object |
Due to the differences in garbage collection approaches between Qore and Python, Qore objects must be managed with a deterministic life cycle; JaPythona objects have only weak references to Qore objects due to the lack of destructors in Python and the lack of determinism in the Python runtime for object lifecycle management.
The callback set here will be called any time a Qore object is created from Python code; if no callback is set, then the standard thread-local implementation is used where Qore objects are saved in a thread-local hash.
- See also
- Managing the Lifecycle of Qore objects from Python for more information
static Python::PythonProgram::setSaveObjectCallback |
( |
*code |
save_object_callback | ) |
|
|
static |
Sets the "save object" callback for Qore objects created from Python code in the root Qore Program context.
- Restrictions:
- Qore::PO_NO_PROCESS_CONTROL
- Example:
hash<string, object> object_cache;
code callback = sub (object obj) {
object_cache{obj.uniqueHash()} = obj;
}
PythonProgram::setSaveObjectCallback(callback);
- Parameters
-
save_object_callback | the callback to save any Qore objects created in Python code, must take an argument of type object |
Due to the differences in garbage collection approaches between Qore and Python, Qore objects must be managed with a deterministic life cycle; JaPythona objects have only weak references to Qore objects due to the lack of destructors in Python and the lack of determinism in the Python runtime for object lifecycle management.
The callback set here will be called any time a Qore object is created from Python code; if no callback is set, then the standard thread-local implementation is used where Qore objects are saved in a thread-local hash.
- See also
- Managing the Lifecycle of Qore objects from Python for more information