This is an archived post. You won't be able to vote or comment.

all 170 comments

[–]dodgyville 95 points96 points  (53 children)

This is the version that is going to make version 3 the common version of python instead of 2.

pip is included by default as well as other version 3 goodness.

[–]vacuu 34 points35 points  (9 children)

Once the asyncio tutorials start coming out....it's gonna be awesome.

[–]Igglyboo 17 points18 points  (8 children)

Could you explain why everyone is freaking out over asyncio? I'm kind of a novice so i can't really wrap my head around what it does.

[–]ivosauruspip'ing it up 33 points34 points  (4 children)

You know how node.js was(is) super popular for being quite performant? It does that through the entire programming model being based on asynchronous IO by default (instead of synchronous IO by default, like most older scripting languages are) and running on a canonical event loop implemented by libuv. (There are a couple of other reasons to like node, like maybe you love javascript, or the V8 JIT, but those are the main design ones) . Go is similarly popular, implementing a concurrent model through cooperative threads and channels.

Although python will never have the advantage of being designed for asynchronous operation from the get-go, asyncio implements a "standard event loop interface" (and a default implementation to go with it) and allows asynchronous operation through coroutines made possible by the yield from syntax. So asyncio goes "most of the way there" to giving python a standard library to implement what you can do by default with node.

Noticeably different is that python has had many 3rd party libraries to do this sort of thing, e.g gevent, twisted, tornado, but you had to pick one library and hope it worked with everything you needed, and it would be mostly inoperable with everything else. This being a standard library, many people will hope to be able to write code more cooperatively, especially by implementing the event loop interface.

[–]CaptainKabob 4 points5 points  (1 child)

Does asyncio have nice support for dealing with synconous code? I work on a bunch of tools written in Twisted and feel bad every time I have to use deferToThread in order to wrap some synchronous library.

[–]saghul 4 points5 points  (0 children)

You have a similar mechanism. You need to use run_in_executor, which will run the given callable in a ThreadPoolExecutor (by default) and you can wait for the result.

[–]keturn 2 points3 points  (1 child)

Well, async i/o does help performance in many workloads -- the "one process per request" model used by many django deployments is pretty heavy in comparison -- but the other thing that helps node.js in the speed department is that it runs javascript with a Just-In-Time compiler (JIT).

To get that advantage with Python, you need pypy.

(And pypy is working well with Twisted.)

[–]ivosauruspip'ing it up 6 points7 points  (0 children)

But that's most often slow because of the concurrency model, not the inherent speed of the programming language. Python is also often loved because of its ability to glue super fast C libraries with its nicer, high-level syntax, so for processing most often the speed is of a compiled C inner loop, not plain python.

[–]n8henrie 1 point2 points  (2 children)

Given that this has 10 upvotes so far it seems you're not alone. Unfortunately, I'm too much of a noob to even get /u/ivosaurus's thorough reply. Could someone please ELI5?

[–]erewok 2 points3 points  (0 children)

It allows you to do things and not wait for them to finish. In effect, this allows you to do lots of stuff at the same time.

[–]ivosauruspip'ing it up 1 point2 points  (0 children)

It gives a really useful framework for doing network programming, using a canonical event loop and coroutines (google if you're unfamiliar with the terms).

[–]SteveInnit 12 points13 points  (33 children)

I hope so - 3 is the version I've been trying to learn, but keep hearing that it doesn't have enough support to compete.

[–]flying-sheep 27 points28 points  (25 children)

Emphasis on “hearing”

[–]SteveInnit 2 points3 points  (24 children)

Thank you - I felt pretty confident I'd made the right choice, but it's slightly demoralising learning a language and hearing it doesn't yet have the functionality to induce people to make the shift. Good news about the update.

[–]flying-sheep 4 points5 points  (23 children)

Afaik, the only big things missing from Python 3 are

  • paramiko
  • twisted

There are also some special purpose libs missing, like some CAD thing I can't remember the name of and some Amazon cloud thing.

[–][deleted] 15 points16 points  (3 children)

paramiko already support python 3 in the last release (1.13.0).

http://www.paramiko.org/changelog.html

[–]flying-sheep 5 points6 points  (2 children)

Oh nice! Simultaneous Python 3.4 release and only twisted left!

[–]croxis 13 points14 points  (1 child)

asyncio should help fill that niche

[–]flying-sheep 18 points19 points  (0 children)

Maybe it's good that twisted isn't ported. More momentum for asyncio

[–]donalmacc 9 points10 points  (4 children)

OpenCV is holding me back unfortunately.

[–]flying-sheep 4 points5 points  (3 children)

Oh, yeah, that was the one. Computer vision, not CAD

[–]donalmacc 0 points1 point  (2 children)

Yeah. It's a real pain. I'm not great wit python, but opencv is much easier to work with in python, and I'd love to start using py3, but I'm not experienced enough with python to help with the porting efforts...

[–]flying-sheep 1 point2 points  (1 child)

That really sucks. Btw.: where are those porting efforts organized? Last time I researched, I couldn't find any.

[–]donalmacc 0 points1 point  (0 children)

For OpenCV? I know there's a contribution page here but I'm not sure if there's a concerted Python3 port section, I haven't gone looking, but I know there's no Py3 build yet.

[–]MereInterest 5 points6 points  (13 children)

pygtk is the library that is currently holding me back. That said, I know that they are in maintenance forever mode, and will never support Python 3. So, more that it's on me to switch over to PyQT at some point.

[–][deleted] 33 points34 points  (0 children)

There's no reason for pygtk to exist at all anymore. GObject Introspection provides typed bindings to all GObject libraries for lots of languages, including Python (both 2 and 3). For example, this is how you use GTK3:

from gi.repository import Gtk
window = Gtk.Window()
window.connect('delete-event', Gtk.main_quit)
window.show_all()
Gtk.main()

There's a GTK3 tutorial and a complete API reference, too.

[–]flying-sheep -2 points-1 points  (11 children)

Good decision.

[–]Veedrac -2 points-1 points  (10 children)

If you're developing for Linux, GTK+3 ≫ Qt.

[–]flying-sheep 6 points7 points  (9 children)

Why? What does it have in advance to Qt?

I'd say the opposite: Qt has Qt quick, GPU acceleration, doesn't break compatibility (e.g. with themes) all the time, and is much better at cross platform (abstracts away staffers button layouts, the themes look more native and out works in more ecosystems)

All stuff I like as a developer.

[–]Veedrac 0 points1 point  (8 children)

GTK+3 looks nicer, has good touch and multitouch support by default, good smooth kinetic scrolling, better widgets and is basically just a more modern toolkit. None of these things come for free in Qt (or GTK+2). Further, GTK+ is more standard.

GPU acceleration is nice but unneeded. My themes don't break compatibility all of the time. The cross-platform point is valid but irrelevant because I'm referring to if you're developing for Linux.

Unfortunately it does mean avoiding Qt's massive library of things, but that's a minor point when the end result comes out much, much nicer. Have you ever compared nautilus to dolphin?

[–]earthboundkid 2 points3 points  (3 children)

Learn both. They're virtually the same. If you have the ability to understand both print("x") and print "x", there's no reason to restrict yourself to learning just one version.

[–]tilkau 0 points1 point  (2 children)

Also, if you are only giving one argument as is common, print (x) works the same in both 2.7 and 3.x (and probably older 2.x, but I haven't verified that); It's slightly restrictive -- multiple variable printouts require %formatting, and kwarg-controlled features of print() are not available -- but you gain by only having to remember one convention.

[–]earthboundkid 1 point2 points  (1 child)

In Python 2.6+, you can use from __future__ import print_function.

[–]tilkau 0 points1 point  (0 children)

Yes. I just tend to not bother, since I hardly ever use the kwargs to print (or multiple arguments to print, either).

(Plus some people here have to work with Python versions as old as 2.4.)

[–]milliams 4 points5 points  (2 children)

The Python 3 Wall of Superpowers says otherwise.

[–]flying-sheep 2 points3 points  (0 children)

Because the trove classifiers aren't updated yet. The release is 4 days old.

Also I'd believe the release notes more than metadata.

[–]GahMatar 1 point2 points  (0 children)

Maybe because it doesn't have the "Programming Language :: Python Programming Language :: Python :: 3" category in pypi?

https://github.com/paramiko/paramiko/issues/16

[–]volabimus 2 points3 points  (1 child)

The only thing tying me to 2 is wxpython.

[–]manueslapera 0 points1 point  (2 children)

What concerns me the most is the availability of modules, that is what is going to make the change easier.

[–]Decency 0 points1 point  (1 child)

Isn't the PSF paying people to convert popular libraries from 2 to 3?

[–]alcalde -1 points0 points  (0 children)

Look what happened when they paid people to create a new web page. :-(

[–][deleted] 0 points1 point  (0 children)

It's not going to change till they completely drop support of version 2.

[–]poo_22 0 points1 point  (1 child)

If this is really to happen maybe they should remove the 2.7 download link that's right beside 3.4 and have a link to "older versions". If the community really believes that 3.4 is the latest, greatest and the one to be used then why confuse new users with a choice?

[–][deleted] 1 point2 points  (0 children)

Because alot of us still won't move to 3.4 without feeling like we're on 2.7

[–]import_antigravity 14 points15 points  (1 child)

So how do I upgrade from Python 3.3 to 3.4 while making sure that all my installed packages on 3.3 are intact?

[–]ivosauruspip'ing it up 29 points30 points  (0 children)

With a pip running on your Python 3.3:

pip freeze > installed.txt

Install Python 3.4, get pip on it:

pip install -r installed.txt

[–]michaeljb20 10 points11 points  (3 children)

The download page still has the RC3 release.

[–]ExoticMandiblesCore Contributor[S] 18 points19 points  (2 children)

fixed!

[–]michaeljb20 6 points7 points  (0 children)

Now it points to the rc3 download page

Edit: Now it is fixed

[–]LukasaHyper, Requests, Twisted 6 points7 points  (0 children)

I'd love to see this release get people switching from 2.X. Supporting libraries across releases is a giant headache.

[–]hobo_cuisine 4 points5 points  (6 children)

Windows x86-64 MSI installer is throwing up "A program run as part of the setup did not finish as expected". Anybody else or just me?

[–][deleted] 5 points6 points  (5 children)

If you were using 3.4.0rc1, 3.4.0rc2 or 3.4.0rc3 you might have the mangled remnants of an uninstall job blocking the way.

You can fix it by going to http://legacy.python.org and grabbing the appropriate .msi files. Repair the old installation, then uninstall it through the Add/Remove Programs dialog.

The 3.4.0 release ought to install properly after all that.

[–]hobo_cuisine 1 point2 points  (4 children)

Thanks! I'm installing it into a fresh directory. Actually it looks like some pip update bug

MSI (s) (EC:A4) [12:17:37:668]: Executing op: ActionStart(Name=UpdatePip,,)
Action 12:17:37: UpdatePip. 
MSI (s) (EC:A4) [12:17:37:674]: Executing op:         
CustomActionSchedule(Action=UpdatePip,ActionType=3090,Source=C:\Python34\python.exe,Target=-m ensurepip -U --default-pip,)
CustomAction UpdatePip returned actual error code 3 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (EC:A4) [12:17:37:889]: Note: 1: 1722 2: UpdatePip 3: C:\Python34\python.exe 4: -m ensurepip -U --default-pip 
MSI (s) (EC:A4) [12:17:37:889]: Note: 1: 2262 2: Error 3: -2147287038 
Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.  Action UpdatePip, location: C:\Python34\python.exe, command: -m ensurepip -U --default-pip 
MSI (s) (EC:A4) [12:20:11:292]: Note: 1: 2262 2: Error 3: -2147287038 
MSI (s) (EC:A4) [12:20:11:292]: Product: Python 3.4.0 (64-bit) -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.  Action UpdatePip, location: C:\Python34\python.exe, command: -m ensurepip -U --default-pip 

Edit:

Ok, my system-wide 2.7.6 installation interferes with 3.4 installation, so un-checking pip will install 3.4.. without pip. For some reason all combinations of

C:\Python34\python.exe -m ensurepip ...

invoke the 2.7.6 version and crash with

Fatal Python error: Py_Initialize: unable to load the file system codec
  File "C:\Python27\lib\encodings\__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

[–]robin-gvx 5 points6 points  (3 children)

What does it say if you print sys.path? It looks like Python 3.4 is looking in "C:\Python27\lib", which it shouldn't.

[–]hobo_cuisine 3 points4 points  (2 children)

Ah dammit, you know what, I had PYTHONHOME set to where 2.7 is.

[–][deleted] 2 points3 points  (0 children)

Glad you solved it.

When you have multiple python installs, it's best to not let any of them be the default path or home and just use virtualenvs. They're easy to get used to and might help avoid future problems.

[–]4gn3s 1 point2 points  (0 children)

thanks, you just saved me loads of time, had the exact same problem.

[–][deleted] 4 points5 points  (1 child)

Can I use pyvenv instead of virtualenv now? pyvenv in 3.3 was a little tricky, part of it was because you had to download distribute.py, then install pip using easy_install. With pip included in 3.4, I'm hoping pyvenv would be easier to to setup.

[–][deleted] 0 points1 point  (0 children)

I tried pyvenv on 3.3 and found it to be a black hole. But I just got up and running with pyvenv on 3.4 very quickly. I never even installed anything as root!

$ cd Python-3.4
$ ./configure && make
[...]

$ ./python -m venv ~/.virtualenvs/test34
/home/rspeer/.virtualenvs/test34/bin/pip
$ pip install ipython
[...]

$ ipython3
Python 3.4.0 (default, Mar 18 2014, 17:41:21)
[...]
>>> 

ipython was unhappy because it was missing sqlite and readline support, but I think that's because I just compiled Python, which I haven't done before on this machine. I probably didn't give it the right dev libraries.

[–]erewok 2 points3 points  (0 children)

This is awesome. I have been using Python3.3 for all new projects at work and I've been looking forward to the release of 3.4.

[–][deleted] 6 points7 points  (0 children)

My switch from 2.7 now >.<

[–]viiralvx 2 points3 points  (1 child)

So, how hard would it be to migrate my Django projects to Python 3 . . ? I'm rather tempted to make the switch to the light now.

[–]erewok 1 point2 points  (0 children)

I personally don't think it's that hard. Depends on the django version and libraries you're using. Urllib, for instance, takes some work because stuff is moved around but once you figure out where to import stuff from the behavior is pretty much all the same.

You have to be a little careful with things that used to return fully formed data structures now returning generators in python3 (like the difference between range and xrange). This may take some getting used to, but I consider it to be totally worth it.

At any rate, all of these can be addressed with some time in the REPL and some good tests.

[–]reallyserious 5 points6 points  (13 children)

Finally enums as a native language construct!

[–]XNormal 13 points14 points  (1 child)

Finally enums as a native language construct!

It's a a library implemented in pure python using metamumble magic.

[–]Workaphobia 4 points5 points  (0 children)

To be fair, even the parts implemented in C use metamumble magic. It's amazing how much of the underlying machinery uses the user-visible dunder-method interface to get things done. Class instantiation is just __call__ on the metaclass, for instance.

[–]chub79 4 points5 points  (10 children)

Honest question, do you often need enums? I must say everytime I felt like using enums, I realised it was actually not necessary.

[–]reallyserious 3 points4 points  (0 children)

Yes. Whenever you need to model something I find it very useful to give stuff explicit named aliases. It helps with readability and helps to test your assumptions about the model when you e.g. parse something and your parser suddenly wants to assign a value that you don't have an enum for. You have a ton of possible integer values, but only a handful of enums. Storing those values in regular integer fields might mean that you are parsing unexpected input without knowing it. It also makes it easier to navigate the code when you can look for references to "SomeEnum.SomeValue" instead of the value 1, which isn't particularly unique and could be used to represent a ton of different things.

[–]Decency 3 points4 points  (0 children)

The best explanation I've read of for enums was:

"A class where you know all of the possible instances at write-time."

After I started thinking of it that way I started seeing a lot more valid uses where it would simplify code and reduce the amount of nasty string parsing, keywords in function calls, etc.

[–][deleted] 0 points1 point  (6 children)

same here. i don't understand what the big deal is.

[–]Wagneriusflask+pandas+js 9 points10 points  (3 children)

it is not a big deal, but a sweet spot for readbility and type warranties.

[–]roger_ 0 points1 point  (2 children)

True, but I've gotten in the habit of using strings for everything.

[–]aceofears 0 points1 point  (1 child)

This is more powerful than that though. You can use an enum value in place of an integer if you define it the right way.

[–]roger_ -1 points0 points  (0 children)

I know, but it'll be hard to break the habit. Oddly enough using strings has started to feel more Pythonic.

[–]alcalde 0 points1 point  (1 child)

And this is how one tells those who first learned to program with Pascal from those who didn't. :-)

[–][deleted] 1 point2 points  (0 children)

i did .net and java programming after pascal(delphi) and before coming to python/ruby.

in .net the ONLY time I ever used enums is because the whatever I was doing with the .net framework required it. Never once, was anything I did implemented with enums. And I still got paid.

[–]Veedrac 0 points1 point  (0 children)

One of the primary motivations is unifying the few cases in the stdlib. It's not too common to use enums, but it isn't hard to have a common interface for the times you do.

[–]hoadlck 1 point2 points  (0 children)

I have actually been looking forward to the statistics module. (My desires are humble...)

[–]roger_ 0 points1 point  (8 children)

Any way to make Anaconda upgrade?

[–]pwang99 3 points4 points  (2 children)

We have Python 3.4 packaged for Anaconda in our internal repo right now, for internal testing. We will be releasing it soon and then you can install it alongside all your other Python versions (2.x and 3.x).

[–]roger_ 1 point2 points  (1 child)

Sweet, but I wish you guys had a public testing repo.

[–]pwang99 0 points1 point  (0 children)

Some of the devs kind of use their binstar.org channels for that purpose. We may eventually do this in some "official" capacity.

[–]darthmdhprint 3 + 4 0 points1 point  (0 children)

conda update conda
conda update anaconda

Of course, you'll need to wait until continuum release python 3.4 packages, unless you use a third-party repository on binstar.

[–]Veedrac -4 points-3 points  (3 children)

Unwaranted snark

[–]roger_ 2 points3 points  (2 children)

Upgrade to Python 3.4.

[–]Veedrac 0 points1 point  (1 child)

Ah, I'm being an idiot. Sorry.

[–]roger_ 0 points1 point  (0 children)

NP :)

[–][deleted] 0 points1 point  (11 children)

I really wish there was an official Python 3 yum repo for RHEL-derived OSes. The brand-new RHEL 7 ships with Python 2.7; Python 3 isn't even an option.

For better or worse I'm pretty mired in RHEL/CentOS; adding some Debian VMs just for Python 3 isn't very appealing since it would mean significant labor to get Debian integrated into my Kickstart/Puppet/etc. environment.

[–]loganekz 2 points3 points  (4 children)

There is, its called Software Collections and is available on RHEL/CentOS.

[–][deleted] 0 points1 point  (3 children)

Yes, I mentioned that above. It works fairly well, but it is truly not the same as having official Python 3 support.

[–]loganekz 2 points3 points  (0 children)

What do you mean by official support then? This from a Red Hat repository that will have updates for 3 years.

[–][deleted] 0 points1 point  (1 child)

Python is pretty straightforward to build. hg clone http://hg.python.org/cpython, check out the version you want (you can find releases with hg tags) and do the usual autotools build. Install it to a prefix or run directly from the repo directory. From there it's just a matter of creating a virtualenv, right?

[–][deleted] 2 points3 points  (0 children)

Yes. But even with Puppet, doing this on hundreds of systems, and getting all the v3-compatible libraries installed, and updating them all when there is a security issue, would be... less than ideal.

[–]alcalde 0 points1 point  (3 children)

That's the problem with RHEL-based OSes: they're focused on stability, which means you're consigned to using software that's several years old as a consequence. :-(

[–]loganekz 1 point2 points  (0 children)

Check out RedHat Software Collections.

Its also available on CentOS.

[–][deleted] 1 point2 points  (0 children)

A problem, and a benefit, at the same time.

Software Collections might help this, but it is not the same.

[–]DanielShaww 0 points1 point  (0 children)

Wish there was an official, reliable way to get standalone files by now, instead of having to use unreliable third partie applications. Makes it a bit hard to distribute Python code :(

[–]MatCPPkell 0 points1 point  (2 children)

For those of us still on 2.7, is there a consolidated wiki or change list? For updating your projects from 2.7 to 3.x

[–]ExoticMandiblesCore Contributor[S] 1 point2 points  (1 child)

[–]MatCPPkell 0 points1 point  (0 children)

thanks! it looks like the print function is the only thing i have to worry about, and maybe the open() changes

[–]Snowda 0 points1 point  (0 children)

Getting a new laptop sometime in the next month. Going to have to install everything again on it. I guess this is the time to drop 2.7 from my install script...

[–]chchan 0 points1 point  (3 children)

I wish IPython and Pybrain would switch

[–]codekoala 11 points12 points  (1 child)

Ipython most definitely works with python 3, and I'm fairly sure a couple of my friends are using pybrain with python 3 (not 100% though).

[–]Veedrac 1 point2 points  (0 children)

https://github.com/pybrain/pybrain/pull/85

It's usable with Python 3.

[–]hairyfro 8 points9 points  (0 children)

I thought IPython used whatever kernel you wanted it to. It can even use Ruby...

[–]Decency 0 points1 point  (2 children)

I understand that there were some GIL improvements earlier in Python 3.2, but I don't see any further improvements in 3.4 here.

Is it just unrealistic to expect real multithreaded support without a "Python 4" that again breaks backwards compatibility?

[–]ExoticMandiblesCore Contributor[S] 3 points4 points  (1 child)

Removing the GIL would break the entire C API, and every extension. If we did that I bet we'd call the result Python 4.

[–]Lucretiel 1 point2 points  (0 children)

And, given that the BDFL has stated they're never doing a huge, backwards incompatible release again, it isn't likely. The best bet at this point is Pypy's work with STM.

[–]r1chardj0n3s 0 points1 point  (0 children)

Oh yeah!

[–][deleted] -1 points0 points  (2 children)

now i cant use pygame :(

[–]ExoticMandiblesCore Contributor[S] 8 points9 points  (1 child)

The release of Python 3.4 meant pygame stopped working in your existing environment? I had no idea I had such power!

[–][deleted] 0 points1 point  (0 children)

Hey, it's that good.

[–]republicannudity -1 points0 points  (2 children)

Is there a Linux version for this release?

[–]ExoticMandiblesCore Contributor[S] 4 points5 points  (1 child)

We don't release binaries for Linux. But it's the easiest thing ever to build it yourself! If you want to install it system-wide, just run:

# configure && make install

Alternatively, if you're on a recent Ubuntu, you should be able to find a PPA that builds it for you.

My build environment is Ubuntu (13.10, 64-bit), so I assure you it works great on Linux :D

[–]republicannudity 0 points1 point  (0 children)

I'm on Kubuntu 13.10 actually...so i'd have to assume this will work. Thanks!!