[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-09-09 Thread John O'Connor
Changes by John O'Connor : Removed file: http://bugs.python.org/file22982/strip_perf.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-09-09 Thread John O'Connor
John O'Connor added the comment: Moved {l,r,}strip to stringlib as well as the bloom filters from unicodeobject. I think it cleans things up nicely. Now there is one implementation for all 3 types. This patch also improves performance for bytearray and slightly for bytes. I see no delta for u

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-08-24 Thread John O'Connor
John O'Connor added the comment: Antoine Pitrou added the comment: > This looks like a dubious micro-optimization. If len == 0, > all loops will exit early anyway (same for similar snippets in bytesobject.c > and unicodeobject.c). You are right about those lines in particular; 'dubious' as y

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-08-24 Thread John O'Connor
Changes by John O'Connor : Removed file: http://bugs.python.org/file23040/unnamed ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-08-24 Thread John O'Connor
John O'Connor added the comment: You are right about those lines in particular; 'dubious' as you say. Though, the point overall was that the general implementation was noticeably faster (regardless of those smaller changes). However, I do think that the single check for len == 0 saves time part

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-08-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: +if (len == 0) { +if (PyByteArray_CheckExact(self)) { +Py_INCREF(self); +return (PyObject *)self; +} +return PyByteArray_FromStringAndSize(NULL, 0); +} This looks like a dubious micro-optimization. If len

[issue12807] Optimizations for {bytearray,bytes,unicode}.strip()

2011-08-21 Thread John O'Connor
New submission from John O'Connor : bytearray() is using a less efficient implementation of split() than its similar friends bytes and unicode. I added a couple extra checks to return early in {bytes,unicode} split(). - if length is 0 - if left strip removed all bytes Looking at just how sim