Re: [pypy-dev] [Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

Hello, On Mon, 30 Mar 2020 23:20:28 -0400 David Mertz <mertz@gnosis.cx> wrote:
I personally don't think it's a "problem style" per se. I'm using it all the time. I'm going to keep using it. We all love Python for being a language which you can easily prototype in, and don't have to concern yourself with implementation details unless you want. My concern for Python to be a language which can be progressively and easily optimized when you need it. Going over the code and changing many lines along the lines of diff: - buf += piece + buf.append(piece) isn't my idea of "seamless" optimization, especially that I know it guaranteedly will grow my memory usage. Sadly I came to conclusion that even - buf += piece + buf.write(piece) patching hurts my aesthetic feelings. At least, that's the only explanation I have for why in one of my modules https://github.com/pfalcon/pycopy-lib/blob/master/utokenize/utokenize.py#L44 I converted one loop from "str +=" to "StringIO.write()", but not another. I then tried to think what could help with that and having += on StringIO seemed to do the trick.
[] -- Best regards, Paul mailto:pmiscml@gmail.com
participants (1)
-
Paul Sokolovsky