Author wolma
Recipients rhettinger, wolma
Date 2018-03-26.15:00:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Given that the random module goes a long way to ensure optimal performance, I was wondering why the check for a match between the random and getrandbits methods is performed per call of Random._randbelow, when it could also be done at instantiation time (the attached patch uses __init_subclass__ for that purpose and, in my hands, gives 10-25% speedups for calls to methods relying on _randbelow).
Is it really necessary to guard against someone monkey patching the methods rather than using inheritance?
Date User Action Args
2018-03-26 15:00:28wolmasetrecipients: + wolma, rhettinger
2018-03-26 15:00:28wolmasetmessageid: <>
2018-03-26 15:00:28wolmalinkissue33144 messages
2018-03-26 15:00:28wolmacreate