Message145186
| Author | pitrou |
|---|---|
| Recipients | loewis, pitrou, vstinner |
| Date | 2011-10-08.20:29:03 |
| SpamBayes Score | 0.00092825893 |
| Marked as misclassified | No |
| Message-id | <1318105744.0.0.664183527644.issue13134@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
In stringlib/fastsearch, instead of using our own loops, we can use memchr() (and, if available, memrchr()) when looking for one-character strings. memchr() is generally quite optimized; on this Linux/glibc machine, I get speedups of 5x-10x:
./python -m timeit -s "large='a'*10000+'b'" "large.find('b')"
-> before: 10.5 usec per loop
-> after: 0.889 usec per loop
./python -m timeit -s "large='b'+'a'*10000" "large.rfind('b')"
-> before: 7.06 usec per loop
-> after: 1.94 usec per loop |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2011-10-08 20:29:04 | pitrou | set | recipients: + pitrou, loewis, vstinner |
| 2011-10-08 20:29:04 | pitrou | set | messageid: <1318105744.0.0.664183527644.issue13134@psf.upfronthosting.co.za> |
| 2011-10-08 20:29:03 | pitrou | link | issue13134 messages |
| 2011-10-08 20:29:03 | pitrou | create | |