Conversation
|
Was about to create an pull request for exactly the same change. Would really like to see this merged into the master branch. |
|
Ping, anyone? |
|
It...doesn't really add much! :P If there were more of an implementation it would be more compelling. Can you give an example of code that was easier to port with this? |
|
From the python docs (https://docs.python.org/3/library/abc.html#abc.abstractmethod), the My personal use case is at https://github.com/rasjidw/sparrowrpc-python/blob/main/src/sparrowrpc/bases.py where I define a number of base classes using both the The is no problems with the classes and decorators being no-op classes / functions in micropython since in cpython it is really just there for developer erganomics and doesn't actually affect the runtime operation in any way. On reflection, it is probably worth adding in the other classes and functions from the abc module as dummy entries too. |
|
Apart from using a metaclass and slots (neither of which MicroPython supports) this is actually the same as CPython which has: class ABC(metaclass=ABCMeta):
"""Helper class that provides a standard way to create an ABC using
inheritance.
"""
__slots__ = ()So I think this is a good addition. As mentioned above, it allows doing |
Just to clarify - it is not so necessary for code that you are porting to micropython, but very useful if you want to have a single codebase that works both with cpython and micropython. |
Actually, this is not completely true, as the cpython ABC class has a method to
So in fact probably better to limit this to the dummy |
This trivial addition will allow less code differences between standard Python classes and MicroPython code. Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
this trivial addition will allow less code differences between standard python classes and micropython code.