Page 1 of 1

how to apply decorators to Python functions implemented in C?

Posted: Mon Jul 23, 2018 2:33 pm
by jickster
how to apply decorators to Python functions implemented in C?

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

Posted: Tue Jul 24, 2018 10:28 am
by stijn
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.