Martijn Faassen: The Call of Python 2.8
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Apr 15 22:51:45 EDT 2014
On Tue, 15 Apr 2014 14:54:53 -0500, Mark H Harris wrote:
> I am noticing the call to 2.8 from time to time (blogs). All along I
> have been seeing the reluctance to migrate to 3.x as either stubborn or
> lazy; or both.
Migrating to 3.x can be a fair amount of work. Not as much work as
migrating to a new language, you get to keep probably 90-99% of the code,
but it's not always easy either.
Converting "print spam" to "print(spam)" is the trivial part of it. The
biggest change between Python 2.x and 3.x is the bytes to Unicode shift,
and that is *not trivial*. Python 2.x tries very hard to make bytes and
strings interoperate even when doing so is the wrong thing to do. So
there is a lot of Python 2 code that is *broken* with respect to strings,
but *seems okay* so long as you only test it using pure ASCII. Python 3
no longer tries to hide the difference, it forces you to confront the
fact that bytes and strings are not the same. To people raised on ASCII-
only programming standards, that's a huge paradigm shift, and a confusing
one. There's a lot to learn, a lot of pain if you don't learn it, and
there can be a lot of effort needed to migrate string code to Python 3.
(Depending on what your code actually does. It is remarkable just how
much string code you can write that works identically in 2.x and 3.x.
Basic string handling remains basic in both.)
The Python ecosystem is a lot bigger than ASCII users, and everyone else
had to suffer with Python 2's string handling so ASCII users don't have
to do anything special. With Python 3, everyone is in the same boat. If
all your data is ASCII, you might be resentful of the need to go to all
this trouble for no apparent benefit, and resentful of Python 3 forcing
you to deal it. But whether you are glad of the changes or wish it was
1959 and you could forget all about the non-ASCII world[1], there is no
doubt that the effort required can be painful.
So migrating costs time, and effort, and money. If you have a 100-line
script, your experience is likely to be very different from somebody
having to migrate a 100,000 line application. People are reluctant to
spend that sort of time and money without clear benefit, and for many
people, Python 2 is "good enough". Apart from Unicode, which many people
do not need, appreciate or even want[2], the benefits of Python 3 are
incremental, not revolutionary, and the cost/benefit ratio is on the
wrong side to justify migration.
This is why Python 2.7 has got such extended support, and why the core
developers are spending so much effort trying to decrease the cost of
migration and increase the benefit. But, ultimately, some people will
decide to never migrate their application to 3.x, because the cost will
always exceed the benefit. That's okay. That's the great thing about
software. So long as you can find hardware that will run Python 2.7, you
can keep running 2.7 for ever. Or 2.3, or 1.5.
> I don't think so any longer. Seems like the reluctance to migrate stems
> from dependencies.
Not anymore. Most -- not all, but the majority -- now support 3.x. Now
the reluctance stems from cost/benefit. If it takes four people a month
to migrate your application, and you pay them $40 an hour (a relatively
low price for software developers, I know some who make in the vicinity
of $200 an hour), that's a direct cost of $25K. Plus the indirect cost of
stuff that they could have been working on in that time but aren't. Would
you pay twenty-five thousand dollars for an upgrade that runs a bit
slower but otherwise has no new functionality that you care about?
This is why Alex Gaynor calls Python 2.7 "the new Cobol". I expect that
most, but not all, small and medium sized Python applications will
eventually be migrated to 3.x, and new applications of any size will be
written in 3.x, but many existing big Python apps will stay on 2.7
forever.
[1] The non-ASCII world includes the USA. Even in the US, there are
common American-English symbols which cannot be written using pure ASCII,
the most obvious being ยข the cent symbol.
[2] Sadly, there are still people who consider Unicode to be unnecessary.
Why can't everyone just learn to write in English? Or if they won't, why
can't I just ignore them and hope they go away?
--
Steven
More information about the Python-list
mailing list