Message307300
The cause of len() been faster than bool() is the same as why repr() is faster than str(). [1] len() and repr() are functions that just call corresponding slots, while bool() and str() are constructors.
In most cases you shouldn't use `bool(obj)` or `len(obj) > 0`. Instead use just `obj` in conditions.
If you can provide a patch that speeds up constructions of simple class instances, please open a pull request on GitHub. Otherwise this issue will be closed.
[1] https://stackoverflow.com/questions/45376719/why-is-reprint-faster-than-strint |
|
Date |
User |
Action |
Args |
2017-11-30 12:10:17 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, dilyan.palauzov |
2017-11-30 12:10:17 | serhiy.storchaka | set | messageid: <1512043817.71.0.213398074469.issue32180@psf.upfronthosting.co.za> |
2017-11-30 12:10:17 | serhiy.storchaka | link | issue32180 messages |
2017-11-30 12:10:17 | serhiy.storchaka | create | |
|