On Mon, 16 Dec 2019 12:12:16 +0100
"R.Wieser" wrote:
> According to me line "PWMType.tp_new = PyType_GenericNew;" creates a
> single instance,
No there is no call to PyType_GenericNew (or tp_new) here - this is
just setting a variable (PWMType.tp_new) to the value PyType_GenericNew
which happens to be a pointer to a function that will (if called) create a
new instance. The important point here is that it is *NOT* being called,
simply referred to and assigned to a variable.
> and than (one of the methods of) that instance is called
> thru accessing the tables "tp_new" field
Er no, the tp_new field is a function pointer which when called
with appropriate parameters will instantiate a new object and return it,
but here it is not being called. This code is to arrange that when it is
called that functionality (required by the definition of tp_new) is
provided by PyType_GenericNew. Without it the first attempt to instantiate
a PWMType would result in a SEGV induced core dump.
In both C and C++ the syntax for 'call this_function' is
this_function() possibly with arguments in the brackets but without the
brackets there is no function being called. The code you are looking at is
an assignment pure and simple with no more side effects than pi = 3;.
--
Steve O'Hara-Smith | Directable Mirror Arrays
C:\>WIN | A better way to focus the sun
The computer obeys and wins. | licences available see
You lose and Bill collects. | http://www.sohara.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|