Idein / py-videocore

Python library for GPGPU on Raspberry Pi
MIT License
792 stars 89 forks source link

Fix qpu decorator not to override the original function name and doc #50

Closed Terminus-IMRC closed 5 years ago

Terminus-IMRC commented 5 years ago

Without functools.wraps, the name and the doc of a function to be decorated will be lost. This PR fixes that.

Example code:

#!/usr/bin/env python3

from videocore.assembler import qpu

@qpu
def qpu_code(asm):
    nop()
    exit(interrupt = True)

print(qpu_code.__name__)

Before the change in this PR, the code prints decorated, which is the name of the decorator. After the change, the output will be qpu_code, which is desired.

nineties commented 5 years ago

Thanks!

Terminus-IMRC commented 5 years ago

Thanks for merging!