how to apply decorators to Python functions implemented in C?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jickster
Posts: 628
Joined: Thu Sep 07, 2017 8:57 pm

how to apply decorators to Python functions implemented in C?

Post by jickster » Mon Jul 23, 2018 2:33 pm

how to apply decorators to Python functions implemented in C?

Online
stijn
Posts: 321
Joined: Thu Apr 24, 2014 9:13 am

Re: how to apply decorators to Python functions implemented in C?

Post by stijn » Tue Jul 24, 2018 10:28 am

Everything related to decoration is done during the compilation phase and results in inserting extra bytecode. So to produce the same effect in C you'd have to do that exactly. Which is probably not easy. The workaround, wrapping the function in a Python module and doing decoration over there, seems more feasible.

Post Reply