In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Are you interested in the practical application of embedding Python into Cmax Candle + releasing resources? Do you want to know about the operation of the actual related functions within it? And the actual introduction of the prototype of its function?
Python uses reference counting mechanism to manage memory to achieve automatic garbage collection. When using the Python object in C _ reference +, reference counting should be handled correctly, otherwise it can easily lead to memory leaks. Macros such as Py_CLEAR (), Py_DECREF (), and so on, are provided in Python/C API to manipulate reference counting.
When you use functions in Python/C API to create lists, tuples, dictionaries, and so on, reference counts for these objects are generated in memory. Macros such as Py_CLEAR (), Py_DECREF (), and so on, should be used to destroy these objects after you have finished working on them. The prototypes are shown below.
Void Py_CLEAR (PyObject * o)
Void Py_DECREF (PyObject * o)
The meaning of the parameters is as follows.
O: the object to operate on.
For Py_CLEAR (), its argument can be a NULL pointer, and Py_CLEAR () does nothing at this time. For Py_DECREF (), its argument cannot be a NULL pointer, otherwise it will result in an error.
The module and function of embedding Python into CumberCandle +
Use the PyImport_Import () function in Python/C API to import the Python module in a C program. The PyImport_Import () function returns a module object. The function prototype is shown below.
PyObject* PyImport_Import (PyObject* name)
The meaning of the parameters is as follows.
Name: the name of the module to import.
Using the PyObject_CallObject () function in Python/C API and the PyObject_CallFunction () function, you can call functions in Python in a C program. The parameter prototypes are shown below.
PyObject* PyObject_CallObject (PyObject* callable_object, PyObject* args)
PyObject* PyObject_CallFunction (PyObject* callable, char * format,...)
For the PyObject_CallObject () function, the arguments mean the following.
Callable_object: the function object to be called.
Args: a list of parameters in tuple form.
For the PyObject_CallFunction () function, the arguments mean the following.
Callable_object: the function object to be called.
Format: specifies the type of parameter.
.: parameters passed to the function.
Use the PyModule_GetDict () function in Python/C API to get a list of functions in the Python module. The PyModule_GetDict () function returns a dictionary. The keyword in the dictionary is the function name and the value is the calling address of the function. The function prototype is shown below.
PyObject* PyModule_GetDict (PyObject* module)
The meaning of the parameters is as follows.
Module: module objects that have been imported.
This is the answer to the question about what the actual operation of Python in the release of resources is when you embed it. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.