[Stackless] flextype and virtual functions
Kristján Valur Jónsson
kristjan at ccpgames.com
Wed Feb 12 21:42:31 CET 2014
I am currently working on removing a piece of internal code called "Flextype" and reorganizing the stackless library. This will involve splitting it into a builting module, _stackless, and a .py module, stackless.py.
One of the things I want to do is to remove functionality that I think is probably not relied upon, in the C api:
certain C api functions that are methods on channes and tasklets, will currently work in a virtual way. This is best explained by an example:
if PyChannel_Send(c, d) is called with an instance of PyChannelType, then an internal C function is invoked as expected.
However, if c is an instance of an inherited type, one that overrides "send", then PyChannel_Send(c, d) will actually behave as if "c.send()" had been called from python code. It will invoke the overriddedn "send" function.
Originally, the idea was that frameworks would perhaps replace the standard classes with subclasses, and still want to pass these through to C code that would work exactly as python code.
However, this is an unlikely scenario, IMHO. Also, this sort of behaviour is very unusual in a pythonesque API: PyList_Append(l, a) is _not_ the same as calling "l.append(a)", because a subclass' "append" method won't be invoked.
Are there any objections to me removing this fringe functionality?
In other news, I'll be removing the modules' __tasklet__ and __channel__ attributes. These are documented to represent the actuall classes created when channels and tasklets are created using the C api and the python functions. However, this is incorrect. These attributes are settable and gettable, but otherwise not used anywhere! Which shows how useful they are.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Stackless