#🐒 monkey-patching Python🐍

1 messages · Page 1 of 1 (latest)

daring umbra
#

The most immediate pitfall you'll run in to with this approach:

import third_party_module
third_party_module.SomeClass = MonkeyClass

is that unless you can be absolutely certain you were the first one in the process to import that module, there will be a whole shell game at play trying to guess who has a reference to MonkeyClass and who still has a reference to the original SomeClass. @vague lake

vague lake
#

yep, i figured that.

#

if i do the monkey-patch at the top of diffusers_pipeline.py before any import diffusers.whatever lines i should be ok though yes?

daring umbra
#

eh, I can't guarantee that, due to a lot of nuances that would take too long to type out and would probably cause you to become quite ill.

but the short version is that it is at least deterministic, so if it seems to be working, it'll probably keep working until things next get shuffled around.