i've been playing with the library for solid hours, and i noticed a possible bug when browsing the source code, the _hooks dict where are the remove handlers are stored is not being cleared after calling keyboard.unhook_all() and i think it should, or else according to what i experimented with it'll build in memory to a huge object depending on the app, and makes things slower. To replicate :
for i in range(100) :
keyboard.hook(print)
print(keyboard._hooks) # prints 100
keyboard.unhook_all()
print(keyboard._hooks) # still 100
a simple fix would be to add _hooks.clear() inside unhook_all()
if i'm wrong i'd appreciate any explanation
i've been playing with the library for solid hours, and i noticed a possible bug when browsing the source code, the _hooks dict where are the remove handlers are stored is not being cleared after calling keyboard.unhook_all() and i think it should, or else according to what i experimented with it'll build in memory to a huge object depending on the app, and makes things slower. To replicate :
a simple fix would be to add
_hooks.clear()
insideunhook_all()
if i'm wrong i'd appreciate any explanation