Pure virtual functions in Python?

Lie Ryan lie.1296 at gmail.com
Sun Feb 21 11:21:44 CET 2010


On 02/21/10 19:27, lallous wrote:
<snip>
> If the base defines the method and it was empty, then my C++ code
> would still call the function. This is not optimal because I don't
> want to go from C++ to Python if the _derived_ class does not
> implement the cb. 

That sounds like a microoptimization; have you profiled your code and
determined that calling empty function causes a bottleneck? I doubt it.

> Now the base class should define it so that doc
> parsers properly describe the base class.

> The recipe suggested is not worth the trouble.
> Unfortunately I cannot use abc module since I use Python 2.5

Because nobody here could have guessed that your dispatcher was written
in C++; your problem is near trivial if your dispatcher is a pure-python
code.



More information about the Python-list mailing list