In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This issue of the content of the editor will bring you about the operation steps of embedding Python into the CCMG + module and function. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Embed Python into freed resources in Candlestick +
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.
Python operation is an introduction defined by Graminit.c
Python embeds C++ to make up for the shortcomings of C++ itself.
An introduction to the powerful functions of embedding Python into CumberCraft +
Required for Python embedding in C _ Candle + (lower level embedding)
Embed Python into the concrete operation of Candlestick + tuple operation for application
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.
Embed Python into Candlestick + modules and functions
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.
The above is the editor for you to share the operation steps of embedding Python into the module and function. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.