[Python-Dev] PEP 414 - Unicode Literals for Python 3

Chris McDonough chrism at plope.com
Mon Feb 27 19:01:02 CET 2012


On Mon, 2012-02-27 at 12:41 -0500, R. David Murray wrote:
> On Mon, 27 Feb 2012 09:05:54 -0800, Ethan Furman <ethan at stoneleaf.us> wrote:
> > Martin v. Löwis wrote:
> > > Am 26.02.2012 07:06, schrieb Nick Coghlan:
> > >> On Sun, Feb 26, 2012 at 1:13 PM, Guido van Rossum <guido at python.org> wrote:
> > >>> A small quibble: I'd like to see a benchmark of a 'u' function implemented in C.
> > >> Even if it was quite fast, I don't think such a function would bring
> > >> the same benefits as restoring support for u'' literals.
> > > 
> > > You claim that, but your argument doesn't actually support that claim
> > > (or I fail to see the argument).
> > 
> > Python 2.6 code:
> >     this = u'that'
> > 
> > Python 3.3 code:
> >     this = u('that')
> > 
> > Not source compatible, not elegant.  (Even though 2to3 could make this 
> > fix, it's still kinda ugly.)
> 
> Eh?  The 2.6 version would also be u('that').  That's the whole point
> of the idiom.  You'll need a better counter argument than that.

The best argument is that there already exists tons and tons of Python 2
code that already does:

  u'that'

Needing to change it to:

  u('that')

1) Requires effort on the part of a from-Python-2-porter to service
   the aesthetic and populist goal of not having an explicit
   but redundant-under-Py3 literal syntax that says "this is text".

2) Won't atually meet the aesthetic goal, as
   it's uglier and slower under *both* Python 2 and Python 3.

So the populist argument remains.. "it's too confusing for people who
learn Python 3 as a new language to have a redundant syntax".  But we've
had such a syntax in Python 2 for years with b'', and, as mentioned by
Armin's PEP single-quoted vs. triple-quoted strings forever.

I just don't understand the pushback here at all.  This is such a
nobrainer.

- C




More information about the Python-Dev mailing list