
Removing Python 2.x support from Django for version 2.0 - ReticentMonkey
https://github.com/django/django/pull/7867/files
======
Flimm
The next release, Django 1.11, will be a long-term support release, and the
one after that, Django 2.0, will no longer support Python 2.

[https://www.djangoproject.com/weblog/2015/jun/25/roadmap/](https://www.djangoproject.com/weblog/2015/jun/25/roadmap/)

I've grow to highly respect the Django project for its good documentation, its
healthy consideration for backwards compatibility, security, steady
improvements and all round goodness.

~~~
Galanwe
Interestingly, I have the exact opposite view on Django.

I hate their API and overall architecture, which I find to be the result of
glueing features on top of features for many years. The internal code also is
just like that: looks like every single method is riddled with out-of-band
conditionals, which is the result of a community that prefers to hack things
to work, instead of rethinking/refactoring.

~~~
stuaxo
Last time I looked a lot of the insides were terrible.

A project I was really impressed with the internals of is Celery (was
expecting the worst having seen Django).

~~~
Ralfp
> Last time I looked a lot of the insides were terrible.

But is it really? Speaking from personal experience it is easy to compare
project with large featureset (and one with heritage) to one with scope on
doing single thing and come with conclusion that smaller, focused codebase is
more consistent and better implemented. At the end of day what matters is if
those terriblenesses actually bite back:

\- is this code changed frequently? Does it need to be changed frequently? \-
is it written in a way that that makes fixes and improvement unbearably
costful? \- is it written in way that allows it to be put apart? How costful
are those individual parts to improve?

Django is large codebase that is worked on by different people and when time
permits this, which means different parts differ in their age, practices, and
ultimately, quiality. This eventually results in codebase that may give
appearance of being messy.

Joel Spolsky explains this nicely in his article about old and large codebases
appearing as hairy and messy to developers:

[https://www.joelonsoftware.com/2000/04/06/things-you-
should-...](https://www.joelonsoftware.com/2000/04/06/things-you-should-never-
do-part-i/)

Especially the part that follows below quote is valuable wisdom to keep in
mind:

> When programmers say that their code is a holy mess (as they always do),
> there are three kinds of things that are wrong with it.

------
yuvadam
This call has been made a while back, and it makes perfect sense. Python 2 is
slowly being EOL'd and if you're starting a brand new Django project there's
no reason on earth you should choose Python 2 anymore.

Sure legacy projects still need support and for that they get the 1.11 LTS,
but otherwise it's really time to move on.

~~~
hueving
Easy to say when you don't depend on C extensions only compatible with 2.7.

~~~
gkya
How hard it is to port a C extension? I don't really know the APIs, but is it
impossible to transform by a script?

~~~
throwawayish
Not hard. You can support 3 and 2 in the same file without much hassle.

Practical example:
[https://github.com/zopefoundation/BTrees/blob/master/BTrees/...](https://github.com/zopefoundation/BTrees/blob/master/BTrees/_compat.h)
[https://github.com/zopefoundation/BTrees/blob/master/BTrees/...](https://github.com/zopefoundation/BTrees/blob/master/BTrees/BTreeModuleTemplate.c)

There are a couple #if PY3K, but not much, really.

I ported a bunch of extension modules, total a couple thousand LOC, and it was
pretty much a matter of reading the docs (see guide at
[https://docs.python.org/3/howto/cporting.html](https://docs.python.org/3/howto/cporting.html)
) and adding a few #ifs. Total time maybe an hour or two.

------
rowanseymour
I'm glad they are making a clean break from Python 2 and I hope this pushes
other projects in the ecosystem to fix those remaining libraries without
Python 3 support. It does get a bit frustrating when things break between
Django releases, but they have a good system of deprecating things for a
couple of releases beforehand. And at the end of the day, Django is for people
who want to build websites, not life support machines... and I think they're
doing a decent job of striking a balance between breakage and stagnation.

------
nodamage
I have a Python 2.7 project that has been running smoothly for many years now
and I'm having trouble finding a reason to upgrade to Python 3. The project
uses the unicode type to represent all strings, and encodes/decodes as
necessary (usually to UTF-8) when doing I/O. I haven't really had any of the
Unicode handling problems that people seem to complain about in Python 2.

Can someone explain what benefit I would actually gain from upgrading to
Python 3 if I'm already "handling Unicode properly" in Python 2? So far it
still seems rather minimal at the moment, and the risk of breaking something
during the upgrade process (either in my own code or in one of my
dependencies) doesn't seem like it's worth the effort.

~~~
bmh100
You gain access to continued language support in 2020. New features involving
strings will have less risk of bugs. The "range" function is more memory
efficient. Integer division automatically floors, reducing bug risk.
Dictionaries with guaranteed ordering. Thousands separator in string
formatting. Bit length on integers. Combinations with replacement on
itertools. New, faster I/O library and faster json. Concurrent futures module.
Ability to define stable ABI for extensions. New CLI option parsing module.
Dictionary-based logging configuration. Index and count on ranges. Barrier
synchronization for threads. Faster sorting via internal upgrade to Timsort.
Async I/O. Support for spawn and forkserver in multiprocessing. Child context
in multuprocessing. Has collision cost reduced. Significantly faster startup.
Type hints. Faster directory traversal. Faster regular expression parsing.
Faster I/O for bytes. Faster dumps. Reduced method memory usage through better
caching. Dramatically less memory usage by random. Faster string manipulation.
Faster propert calls. Formatted string literals (interpolated strings).
Asynchronous generators. Asynchronous comprehensions.

How much faster might your code run just by upgrading to Python 3? How much
memory might you save?

~~~
Buttons840
> Dictionaries with guaranteed ordering.

I don't think you're suppose to depend on the ordering of dictionaries. It's
an implementation detail which might get changed, although it wont actually
ever be changed because people will come to depend on it.

~~~
bmh100
I'm specifically referring to OrderedDict in this case, which does have
guaranteed, insertion-based ordering. It was introduced in 3.1, circa 2009,
via PEP 372.

~~~
wolf550e
[https://docs.python.org/2/library/collections.html#ordereddi...](https://docs.python.org/2/library/collections.html#ordereddict-
objects)

> New in version 2.7.

~~~
bmh100
That's a good point. I didn't realize that it was also introduced into 2.7 at
the same time.

------
stevehiehn
Good. I've been getting into python a bit because i have an interest in
datascience. I'm mostly a Java dev. I have to say the python2/3 divide is a
real turn off. Many of the science libs want to use seem to be in 2.7 with no
signs of moving.

~~~
joeyspn
> Many of the science libs want to use seem to be in 2.7 with no signs of
> moving

The most important scientific libraries have pledged to drop support before
2020, and are all python3-ready

[http://www.python3statement.org/](http://www.python3statement.org/)

~~~
lmm
Is there any hope of other libraries and OSes doing the same thing?

I used to work on a GUI app in Python. I ported it to Python 3, then switched
OSes for various reasons. _5 years on_ , on Ubuntu Xenial (so new I can't even
use it in Travis, but that's a separate whine), I install pykdeuic4 and it's
using Python 2. So I've basically abandoned that project for 5 years now,
because every time I looked at it I thought "surely Python 3 will be here in a
few months, I don't want to port backwards to Python 2".

(Serious question: is there a PPA or anything I can use to get these things
for Python 3? I need PyQwt as well as PyKDE)

~~~
xioxox
Have you tried python3-pykde4? It seems to contain a pykdeuic4.py file.

~~~
lmm
No - but you've set me on the right track, there looks to be a pykdeuic4-3.4
executable (I had assumed if there were anything like that it would be a case
of update-alternatives, but apparently not?). Will try that when I get home.

~~~
StavrosK
In general, I've found that Ubuntu versions of the last 1-2 years support
Python 3 fine, you just have to use the "python3-*" packages.

~~~
lmm
Fair enough. E.g. I was assuming the reason PyQwt didn't exist for python3 was
because Ubunty hadn't packaged it, but having looked further it seems the
library itself is unmaintained.

------
oliwarner
A whole pile of people complaining about upgrading Django highlights two
things to me:

Not enough people are using tests. A decent set of tests make upgrade super
easy. The upgrade documentation is decent so you just spend 20 minutes
upgrading broken things until it all works again.

People pick the wrong version. I've seen people develop and even deploy on
-dev and it makes me cry inside because they'll need to track Django changes
in realtime or near enough. Pick an LTS release and you get up to three years
on that version with security and data-loss upgrades and no API changes.

------
misterhtmlcss
Is anyone going to talk about what this means for Python and Django? I read
the first 30-40 comments and they are all about off topic stuff related to
Django, but still the core premise is the committed move to Python 3.x going
forward.

What do people think of that?! I'm a newer dev and I'd really really love to
hear what people think of that and what it means for the future rather than
side conversations about how bad their API is, how good it is, how good their
Docs are and how bad they are.... Blah blah.

Please!! This community is filled with some of the most brilliant minds and I
for one don't want to miss out on this chance to hear what people think of
this change.

Please please don't reply that you disagree with my POV. That's irrelevant,
but please do if you are interested in the initial topic. I'd be be very
excited to hear your thoughts.

So Django moving to Python 3.X Go :)

~~~
spiffyman
First, this is a good thing for the community. The ecosystem has been pretty
well prepared for 3.x adoption for a while, but we just haven't done it.
Still, when Django switched its default docs to use 3.x instead of 2.x, it
noticeably increased adoption of 3.x. (Source: Kenneth Reitz on "Talk Python
to Me" episode #6.) By pushing on with 3.x, Django is doing its part to drag
the rest of us forward with it.

Second, this is necessary. Support for Python 2.x is supposed to end in 2020,
per Guido's keynote at PyCon 2016, so Django is going to have to get in line
in ~3 years one way or the other. A major version increment is a great time to
introduce such a breaking change.

So ... "what this means" is that Django is doing what it has to do, which
happens to coincide with the interests of the community at large. _shrug_ I'm
glad it's happening, but there shouldn't be a whole lot of drama or hand-
wringing here.

------
gkya
This is a nice patch [1] to review for Python coders. Seems to me that most
incompatibilities are provoked by the unicode transition.

[1] [https://patch-
diff.githubusercontent.com/raw/django/django/p...](https://patch-
diff.githubusercontent.com/raw/django/django/pull/7867.patch)

------
erikb
There are only two possible opinions here:

A) You mostly have Python3 projects: Then you like it because you know more
ressources will be spent on your pipeline and having more Py3 packages is also
helpful.

B) You still have Python2 projects: You hate it, because it pushes you out of
your comfort zone.

But I have to say, we want our langauges to develop as well. We want our
packages to get attention. And there was lots of time to switch and experiment
with switching. Ergo, it should happen. Even if you don't like it as much,
that's where things are heading. Deal with it, move on. Let the community help
you, if necessary.

------
karyon
The related django issue is here:
[https://code.djangoproject.com/ticket/23919](https://code.djangoproject.com/ticket/23919)

there are lots of other cleanups happening right now. It's a real pleasure to
look at the diffs :)

------
myf01d
I hope they just find a way to support SQLAlchemy natively like they did with
Jinja2 because Django ORM is really very restrictive and has numerous serious
annoying bugs that have been open since I was in high school.

~~~
anentropic
> Django ORM ... has numerous serious annoying bugs

Such as?

I've worked primarily with Django for years and I think if the ORM really had
"numerous serious annoying bugs" I'd have a mental library of these things to
watch out for. But I can't think of any ORM bugs off the top of my head, I
don't really remember encountering any.

We all know SQL Alchemy is 'better' and there are things Django ORM can't do,
but 99% of the time it's adequate.

Are you sure you didn't mean "features I wish it had"...?

~~~
myf01d
such as

1\. multi-column primary key.

2\. annotate several counts for some query correctly.

that what I remember for now.

~~~
jsmeaton
1\. Would be a new feature, not really a bug. There have been multiple
attempts to resolve which have all failed. DEPs exist to address this
shortcoming.

2\. Yep. Still a crappy situation to be in, but one that's also tricky to
solve due to not being able to control the joins across multi-valued
relationships.

------
ReticentMonkey
reddit discussion at /r/python :
[https://www.reddit.com/r/Python/comments/5otufg/django_20_no...](https://www.reddit.com/r/Python/comments/5otufg/django_20_now_on_master_will_not_support_python_2/?ref=share&ref_source=link)

------
Acalyptol
Time to introduce Python 4.

~~~
disconnected
I'm still waiting for Python 3.11 for Workgroups.

------
gigatexal
This is great news. It will help move people off their python 2 code bases
even more. Kudos to the Django team.

------
karthikp
Oh boy. And here I am still using Py2.7 with Django 1.6

~~~
Ensorceled
I'm in the midst of upgraded a 1.6 project to 1.10 and Python 3. Wish me
continued success :-)

~~~
karthikp
I've been trying that for the past 1 year with no luck. Product always takes
higher priority.

Make sure you have dedicated time for the migration

~~~
Daishiman
This is not a sustainable position to be in. Migrations _are_ product issues.

------
gojomo
Because incrementing version numbers is free, Django might as well bump the
Python-3-requiring version number to Django 3.0.

Lots of beginners and low-attention devs will find "Django 3 needs Python 3"
easier to keep straight than "Django 2 needs Python 3".

------
mark-r
I was surprised to see the elimination of the encoding comments, I thought
that the default encoding would be platform dependent. After a little research
I found PEP 3120 which mandates UTF-8 for everybody, implemented in Python
3.0. It also goes into the history of source encoding for 1.x and 2.x. I
wonder why there aren't more problems with Windows users whose editors don't
use UTF-8 by default?

~~~
rowanseymour
Makes sense given Python 3 lets identifiers contain non-ascii characters, e.g.
café=123, 变量="x"

~~~
mark-r
I'm all-in on the usefulness of UTF-8, I wish there was a way to configure
Windows to reliably use it as its default character encoding. If I create a
file with Notepad containing the line café=123 and save it without specifying
an encoding, I can't import it into Python. I spend a lot of time on
StackOverflow and I don't remember seeing that problem come up.

------
romanovcode
Good, it's about time this nonsense ends.

~~~
jdimov11
This is the beginning of the Python 3 nonsense, not the end yet. It will end
when the Python 3 joke is scrapped and replaced with Python 4 as a SEAMLESS
continuation of Python 2.

~~~
singularity2001
Don't know why you were downvoted: still waiting for a seamless Python X
upgrade as well, without code duplication.

~~~
stefantalpalaru
It already exists, as a Python2 fork:
[https://github.com/naftaliharris/placeholder](https://github.com/naftaliharris/placeholder)

~~~
billoday
This is the greatest thing ever - for systems work, python3 is a nightmare.
Thanks for sharing this.

~~~
detaro
What's special about "systems work" that makes python3 worse in your
experience? (also, was is "systems work" for you, since I might be
misinterpreting that -> I am assuming "low-level unix scripting" or something
like that)

~~~
billoday
In my last three companies, the bulk of the infrastructure was defined and
managed via Python scripts (a lot of this predated Ansible being great), so
what gets forgotten is the literal billions of lines of custom wrappers and
classes that are broken, usually on the print statement v function debate or
how string formatting works. I can't justify hiring someone to dig through all
that code just to bring it up to snuff and everything needs tweaking. Usually
we end up just writing new code in another language and call it from python or
the other way around. I can't seem to get comfortable handling both versions
in one project without getting REALLY frustrated. So, yeah, a fork with the
niceties from python3 that allow my tech debt to still run (and hopefully
better), allowing me to replace bits (likely into non python languages - Go is
growing on me) at a time and not en masse is pretty frikken awesome.

------
ReticentMonkey
Can we expect the async/await introduced from Python 3 for async request
handling or maybe some heavy operations ? Something like sanic:
[https://github.com/channelcat/sanic](https://github.com/channelcat/sanic)

~~~
lewiseason
It seems like that'll come, but that it'll cause some issues with some WSGI
implementations.

[https://www.reddit.com/r/Python/comments/5otufg/django_20_no...](https://www.reddit.com/r/Python/comments/5otufg/django_20_now_on_master_will_not_support_python_2/dcmiiv3/?st=iy4izox8&sh=e27de429)

------
hirokiky
Say good bye to django.utils.six. yay

------
alanfranzoni
So, after a poor evolution strategy that lead the Python world to be split in
two and forces maintainers to offer two versions for the same library, and
upstream maintainers to offer support for two different python versions, the
same is happening for Django!

I speculate that the latest Django 1.x will remain used - and possibly the
most used - for a lot, lot of time.

~~~
alanfranzoni
Please, don't tell me how "Python3 is good" \- I know everything. I just still
don't approve the way the transition was made - if we got to Python 3 through
progressive deprecation and evolution via python 2.8 and 2.9, we wouldn't be
where we are now.

~~~
Al-Khwarizmi
Or if they had called Python 3 a different name, and let both branches evolve
freely and compete.

~~~
gtaylor
This sounds like a fork. Nothing need stop someone from forking and
maintaining CPython 2.x. Open source is a do-ocracy.

But I doubt it'd be worth it. Python 3 is getting great traction and is a
fundamentally better language.

~~~
Al-Khwarizmi
Python 3 is already a fork.

The problem is that Python 2 cannot evolve freely alongside Python 3, because
even if someone wants to maintain it and keep releasing versions, the Python
Software Foundation won't let them use the name Python (there was a post some
weeks ago about someone who actually tried). So there is no free competition
between 2 and 3. 2 has been basically killed by a decision from above.

Don't get me wrong, I'm no Python 3 hater. In fact, I have some projects in
Python 3 and I would leave Python 2 if I could. But I, like many people, have
to code stuff that has dependencies on Python 2, and the way they have handled
the update bothers us for no good reason. In fact, the whole schism fiasco is
making me use less Python and more Java, where my stone-age code still runs,
lately.

~~~
slig
> the Python Software Foundation won't let them use the name Python

That's how trademarks are supposed to work; they must go after anyone using
without permission or they lose it.

~~~
true_religion
Or they could give permission.

~~~
rbanffy
And have a confusing set of different and incompatible languages with the same
name?

People are complaining about Python 3 being named Python because some code
breaks under it. That would be hell.

~~~
true_religion
You already have Python 2. This is a continuation of it that is simply closer
in semantic to Python 3. How could it be bad if apart from the Unicode
semantics the two versions became equivalent?

~~~
rbanffy
There is no guarantee the two branches would converge.

Some things that are very useful are backported to 2, but others are just too
much work.

------
daveguy
Seriously? The entire change to "unsupport" the majority of Python code is a
mass delete of from __future__ import unicode_literals and utf-8 encoding? Is
that really the extent of the "too difficult to maintain" code? There will be
a split.

~~~
jsmeaton
Just one step.
[https://code.djangoproject.com/ticket/23919](https://code.djangoproject.com/ticket/23919)

~~~
daveguy
Gotcha. Thanks for the clarification (actually 2 of those steps). This is a
great reference.

~~~
Ensorceled
Also factor in halving the on going QA, testing and environment dependent bug
fixing efforts.

------
scrollaway
Oh my god stop. You're all over this thread. _What bit you_?

 _This is the price you pay for staying on an old version_. You do not get to
stick to an old version AND demand that others do too.

You CAN stay on Python 2. You CAN stay on Django 1.11. It's LTS. So is Python
2.7. You get to use both until 2020 with no issues. After that, not upgrading
is a technical debt that will start to accrue, faster and faster as you can no
longer use recent versions of various software.

You are free to make your infrastructure immutable; you then become
responsible for it of course. And the money you're not willing to spend
porting to Python 3 today will be money you spend on costs related to being on
outdated infrastructure, years in the future. That's a tradeoff. Banks do it a
lot I hear. A bunch of companies still use ancient hardware and technologies
nobody would think of starting a business with today. These companies make
billions.

You know what the employees of these companies aren't doing? They're not
bitching on HN that the tech they're using is no longer supported.

~~~
coldtea
> _Oh my god stop. You 're all over this thread. What bit you?_

As someone who has 6 comments in this thread yourself, I don't think you are
in position to complaint.

I also find "what bit you" and "please stop" rude. You don't get to dictate
what others opinion should be.

> _This is the price you pay for staying on an old version. You do not get to
> stick to an old version AND demand that others do too._

7+ years on and the "old" version has more users than the new one. That's a
fact supported by numbers. So maybe you want to recheck with reality whether
the transition was a success instead of arguing with me?

Not all transitions go well, the Perl 6 transition killed Perl, the PHP 4 to 5
transition (another major one) went quite smoothly.

~~~
scrollaway
> _As someone who has 6 comments in this thread yourself, I don 't think you
> are in position to complaint._

This isn't a numbers contest. Unlike yours, none of my comments are shitting
on the efforts of volunteers that are doing their best to keep people like you
happy and making money using a project you're not paying for.

> _So maybe you want to recheck with reality whether the transition was a
> success instead of arguing with me?_

You completely missed the point.

~~~
Chris2048
> making money using a project you're not paying for

says who? It this the standard FOSS strives for?

~~~
scrollaway
Where do you get the idea that it's OK to "demand" things from a project when
you're not paying for it?

FOSS gives you freedom to do these things on your own. Money gets you other
people doing it for you.

~~~
Chris2048
Why is "demand" in scare-quotes? I never said that, and it's a loaded term.

The issue here is suggesting you shouldn't freely _criticise_ flaws in FOSS
software. This is harmful, and goes directly to affecting information people
have available to them in choosing whether or not to use a piece of software
in the first place.

Do you actually know what money/time OP might be spending, losing, or making
on Django?

> FOSS gives you freedom to do these things on your own. Money gets you other
> people doing it for you.

What a cop out. A lack of being paid (money at least) doesn't imply no
obligations, nor freedom from criticism.

Do you speak for every Django contributor?

~~~
scrollaway
> _Why is "demand" in scare-quotes? I never said that, and it's a loaded
> term._

Because I was referring to coldtea's demands.

> _What a cop out. A lack of being paid (money at least) doesn 't imply no
> obligations, nor freedom from criticism._

Excellent, then you should be fine with me criticizing the attitude that's
been displayed here.

> _The issue here is suggesting you shouldn 't freely criticise flaws in FOSS
> software. This is harmful, and goes directly to affecting information people
> have available to them in choosing whether or not to use a piece of software
> ion the first place._

Why is this the conclusion you draw from my posts? I said it before, the
Python 3 transition sucked. It's something we kind of all agree on. There is
plenty of criticism to be made.

However, I really want to recontextualize this: Django is an open source
project, maintained by a non-profit. Python is an open source project,
maintained by a non-profit. The projects in question, with "tens of millions
of lines of Python 2 code" (only a tiny amount of which would need to be
ported, but I disgress...), are most often for-profit projects. Yeah, it's a
bit rich.

This is the same as the IE6 situation: Want support for it? Pay extra for it!
You should not expect free support for technology for which the EOL was
announced years in advance just because you're using a lot of it. And you will
have _no issue_ finding paid support. Heck tell you what, if you do, shoot me
an email, I do contract work sometimes.

You know why FOSS is great? It's great because the PSF/DSF do not get to
revoke your license to use the software they're no longer supporting. You get
to use it forever. This is your freedom and it's a _good one_. Make use of it!

~~~
Chris2048
Which comments are you interpreting as demands?

>> A lack of being paid (money at least) doesn't imply no obligations, nor
freedom from criticism.

> Excellent, then you should be fine with me criticizing the attitude that's
> been displayed here.

Great. Do you actually have a response to this point in context, then?

> This is the same as the IE6 situation: Want support for it? Pay extra for
> it!

You did not argue this. You said "shit on", which doesn't translate to
"demanding support". you are deflecting from the one thing I _actually_
criticised.

Your strawman is "support is being demanded" \- this isn't the case. Any
further arguments on that topic are just beating the strawman.

Furthermore, _oficially_ changing the direction of Django also may affect
contributions, changes to the roadmap or architectural design for example.

~~~
scrollaway
You're appropriating criticism that was not directed to you, but to coldtea.
Here and elsewhere.

Edit: Yes, _appropriating_. You're taking criticism I specifically directed at
coldtea, applying them to your comments and then complaining it doesn't fit. I
am done talking to you.

Edit 2: This was not meant to sound as aggressive as it did, sorry.

~~~
dang
You've been breaking HN's civility rule with bits like "I am done talking to
you", "Oh my god stop", "bitching on HN", etc. That's not cool, regardless of
how wrong other commenters may be. Please take greater care to be respectful
in comments here.

[https://news.ycombinator.com/newsguidelines.html](https://news.ycombinator.com/newsguidelines.html)

[https://news.ycombinator.com/newswelcome.html](https://news.ycombinator.com/newswelcome.html)

------
belvoran
A VERY GOOD NEWS!!!

Yea, I know, shouting is not the best thing, but this is a really good news.

------
jonatron
Django was designed for making content based sites and CMS's quickly. It
wasn't designed for webapps and REST APIs, and it can be used in those cases,
but it's not great. I'd look at other options.

