[Python-ideas] Python 3.x and bytes
Nick Coghlan
ncoghlan at gmail.com
Mon May 23 08:02:18 CEST 2011
On Mon, May 23, 2011 at 1:46 AM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> The question is how far to go with polymorphism, etc. I think that
> Nick's urlparse work gets the balance about right, and see only danger
> in more stringlike bytes (eg, by returning b'b' for b'bytes'[0]).
> OTOH, there are some changes that might be useful but seem very
> low-risk, such as a c'b' literal that means 98, not b'b'.
If we did go with an ord() literal, I would actually favour something
more like 0'b'.
However, as Maciej pointed out off-list, adding a new literal type
because calls to builtin functions have a relatively high overhead in
CPython even with constant arguments probably isn't a good idea.
Better to just write "ord('b')" and use PyPy to make it fast
(Alternative for use with -O rather than PyPy: "ordb = 98; assert ordb
== ord('b')").
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list