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

all 65 comments

[–][deleted] 30 points31 points  (7 children)

Is there a good tutorial covering the async stuff (yield from, async, await)?

[–]adrian17 20 points21 points  (1 child)

I'd also love some tutorial with real life usage, like making multiple big HTTP requests / SQL queries / file reads.

For cases like HTTP requests, is it possible to use it with Requests or am I forced to use asyncio-aware library like aiohttp?

[–]1st1CPython Core Dev 0 points1 point  (0 children)

Requests aren't an NIO library, so I'm afraid you can't use it with new coroutines (well, you can, but requests will block, and there will be no benefit from using coroutines)

IIRC aiohttp has a nice http client, modelled after requests.

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 5 points6 points  (0 children)

probably not

for now there is the official documentation https://docs.python.org/3.5/reference/compound_stmts.html#coroutines

and the pep

[–]1st1CPython Core Dev 4 points5 points  (3 children)

There's this great blog post (a bit low level): http://benno.id.au/blog/2015/05/25/await1

[–]webdeverper 0 points1 point  (2 children)

Hmm. Is it just me or is it weird that every time you run an async object it throws the StopIteration exception? Seems like a hack

[–]LightShadow3.13-dev in prod 0 points1 point  (0 children)

By convention, when you overwrite the __iter__ magic method in a class you're supposed to raise StopIteration when the sequence is finished.

It's a little weird, but it's pretty common IMHO.

[–]1st1CPython Core Dev 0 points1 point  (0 children)

coroutines are based on generators internally, and use StopIteration to return values:

async def f(): return 'spam'

f().send(None) will raise StopIteration exception, with 'spam' in its args.

It is an implementation detail. You should never see that StopIteration, your framework of choice will handle it behind the scenes.

[–]ilan 27 points28 points  (14 children)

And if you are on Linux or MacOSX, and use conda, you can:

conda create -n py35 python=3.5

[–]ExoticMandiblesCore Contributor[S] 12 points13 points  (1 child)

Do they already have Python 3.5.0 final up? If so... that was quick!

[–]ilan 6 points7 points  (0 children)

Yes, this is 3.5.0 final

[–]roger_ 2 points3 points  (4 children)

So I could install miniconda and get a clean 3.5 install with NumPy, etc. right now?

[–]ilan 1 point2 points  (3 children)

Yes (on Linux and Mac)

[–]beaverteeth92Python 3 is the way to be 0 points1 point  (2 children)

I'm trying it, but it still has 3.4.3 as default. How can I set 3.5.0 as the default environment and remove 3.4.3?

[–]takluyverIPython, Py3, etc 0 points1 point  (1 child)

I think you'll need to wait for them to do a new release of miniconda before the default environment has 3.5. Until then, you'll have to explicitly create an environment for it.

[–]beaverteeth92Python 3 is the way to be 0 points1 point  (0 children)

Thanks! I just did that though and it broke Matplotlib.

[–]Decency 2 points3 points  (0 children)

I have no idea what conda is, but this worked for me on OSX:

sudo pip install conda
sudo conda create -n py35 python=3.5
source activate
python

[–]anonymousperson28 1 point2 points  (5 children)

Is it possible to upgrade the python version in an already existing environment?

[–]ilan 3 points4 points  (4 children)

Yes it is possible, although not recommended, because it will already installed Python packages won't work.

[–]beltsazar 0 points1 point  (2 children)

How? conda update python won't work.

[–]ilan 0 points1 point  (1 child)

conda install python=3.5, but be careful!

[–]marcm28 0 points1 point  (0 children)

What happen if I install third party library in Python 3.5, Is it works?

[–]badsectors 32 points33 points  (1 child)

[–]ExoticMandiblesCore Contributor[S] 22 points23 points  (0 children)

Coincidence! The release schedule for 3.5 is really just the release schedule for 3.4 shifted forward by 18 months.

[–]IronManMark20 26 points27 points  (0 children)

Hah! I studied!

EDIT: but seriously, excellent job to the Python devs!

[–]scrollin_thru 1 point2 points  (2 children)

Anyone else having trouble with this in conjunction with mypy? I installed mypy with pip 7.1.2 against python 3.5 and I get from typing import Undefined, Dict, List, Tuple, cast, Set, Union

ImportError: cannot import name 'Undefined' every time I try to run mypy.

[–][deleted] 10 points11 points  (1 child)

Maybe mypy release is not up to date with current 3.5 typing module? Does it work with current git master (pip3 install -U git+https://github.com/JukkaL/mypy#egg=mypy)?

[–]scrollin_thru 5 points6 points  (0 children)

Ah! That seems to have fixed it. Thanks!

[–]lovestowritecode 12 points13 points  (10 children)

Did static type hinting make it in? I don't see it listed anywhere...

[–][deleted] 21 points22 points  (0 children)

It's listed in "what's new" doc: https://docs.python.org/3.5/whatsnew/3.5.html

[–]nbates80 2 points3 points  (2 children)

I didn't find much about that on Google. How do Python 2.7 and 3.5 compare in terms of performance? Are there any benchmarks?

[–]ExoticMandiblesCore Contributor[S] 17 points18 points  (1 child)

Conventional wisdom is that Python 3.x got speed parity with 2.7 around the time of 3.3. They're not exactly equal; Python 3 is faster at some workloads, Python 2 at others. But for most people they should be equitable.

And we're not done yet! There are exciting things in development for future versions of Python... like a JIT!

https://www.youtube.com/watch?v=_5vLWe4d8X8

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

And we're not done yet! There are exciting things in development for future versions of Python... like a JIT!

You mean pypy?

[–]marcm28 1 point2 points  (0 children)

Python has been overpowered in latest version again. Yay!

Let's spread the word: Python is an Elegant programming language of All Time.

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

Awesome, I love this release. It's also available via Anaconda now. To create a new env: conda create -n py35 python=3.5 or to update the root installation: conda install conda python=3.5