Message185992
ord(max(s)) == max(map(ord,s)) == ord(max(s, key=ord))
Using a*30000000 and mental counting, the first is clearly fastest (about 2 seconds) with a 3.4 build, which has the optimized string comparison patches from last October. The reduction to 3 categories takes almost no time.
I'm -1 without some real use case. For most testing, the data are constructed, so we already know the CPython internal width.
There is no comparison in importance between and len/__len__. bool(x) calls x.__len__ if no x.__bool__. strings and other builtin collection classes have no __bool__.
> .. cost little or nothing
Every addition has a real cost: for developers, write code, write test, test test, write doc, maintain; for users, more to learn and understand -- and forget. I doubt the value of the compute time saved would ever come close to the value of the human time expended. There is also a cost to adding something CPython-specific. |
|
Date |
User |
Action |
Args |
2013-04-04 01:55:20 | terry.reedy | set | recipients:
+ terry.reedy, loewis, vstinner, ezio.melotti, Rosuav |
2013-04-04 01:55:20 | terry.reedy | set | messageid: <1365040520.52.0.441998081913.issue17629@psf.upfronthosting.co.za> |
2013-04-04 01:55:20 | terry.reedy | link | issue17629 messages |
2013-04-04 01:55:20 | terry.reedy | create | |
|