Author pitrou
Recipients arjennienhuis, benjamin.peterson, christian.heimes, eric.smith, exarkun, ezio.melotti, glyph, gvanrossum, loewis, martin.panter, pitrou, serhiy.storchaka, terry.reedy, uau, vstinner
Date 2013-01-22.20:13:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1358885448.3460.17.camel@localhost.localdomain>
In-reply-to <28130E51-CBC2-48C2-886D-DEA001B8B78D@twistedmatrix.com>
Content
>  there are plenty of other Python applications that don't use Twisted
> which nevertheless need to emit formatted sequences of bytes.

The fact that "there are plenty of other Python applications that don't
use Twisted which nevertheless need to emit formatted sequences of
bytes" is *precisely* a good reason for this to be discussed more
visibly. Even if it isn't a PEP, it will still benefit from being a
python-dev or python-ideas discussion. We are talking about a method on
a prominent built-in type, not some additional function or method in an
obscure module.

> > I also kind of expect Twisted to have worked around the issue before
> 3.4 is out, anyway.
> 
> The problem is impossible to work around in the general case.

I'm not sure what the "general case" is. What I know from Twisted is
there are many specific cases where, indeed, binary protocol strings are
formed by string formatting, e.g. in the FTP implementation (and for
good reason since those protocols are either ASCII or an ASCII
superset). As a workaround, it would probably be reasonable to make
these protocols use str objects at the heart, and only convert to bytes
after the formatting is done.

> This has negative readability, performance, and convenience
> implications for the code running on both 2.x and 3.x and it would be
> really nice to see fixed.

Code running on both 2.x and 3.x will *by construction* have some
performance pessimizations inside it. It is inherent to that strategy.
Not saying this is necessarily a problem, but you should be aware of it.

>   Honestly, it would still be a porting burden to have to
> use .format(); if you were going to do something _specifically_ to
> help Twisted, the thing to do would be to make both .format
> and .__mod__ work; most of our protocol code currently uses % to do
> its formatting.

I know that :-)
History
Date User Action Args
2013-01-22 20:13:27pitrousetrecipients: + pitrou, gvanrossum, loewis, terry.reedy, exarkun, vstinner, eric.smith, christian.heimes, benjamin.peterson, glyph, ezio.melotti, arjennienhuis, uau, martin.panter, serhiy.storchaka
2013-01-22 20:13:26pitroulinkissue3982 messages
2013-01-22 20:13:26pitroucreate