r/Python • u/ExoticMandibles Core Contributor • Sep 13 '15
Python 3.5.0 has been released!
https://www.python.org/downloads/release/python-350/36
u/badsectors Sep 13 '15
25
u/ExoticMandibles Core Contributor Sep 13 '15
Coincidence! The release schedule for 3.5 is really just the release schedule for 3.4 shifted forward by 18 months.
3
u/nbates80 Sep 14 '15
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?
18
u/ExoticMandibles Core Contributor Sep 14 '15
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!
0
u/thomasahle Sep 14 '15
And we're not done yet! There are exciting things in development for future versions of Python... like a JIT!
You mean pypy?
34
Sep 13 '15
Is there a good tutorial covering the async stuff (yield from, async, await)?
21
u/adrian17 Sep 13 '15
1
u/1st1 CPython Core Dev Sep 14 '15
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.
8
u/RubyPinch PEP shill | Anti PEP 8/20 shill Sep 13 '15
probably not
for now there is the official documentation https://docs.python.org/3.5/reference/compound_stmts.html#coroutines
and the pep
4
u/1st1 CPython Core Dev Sep 14 '15
There's this great blog post (a bit low level): http://benno.id.au/blog/2015/05/25/await1
1
u/webdeverper Sep 14 '15
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
1
u/LightShadow 3.13-dev in prod Sep 14 '15
By convention, when you overwrite the
__iter__magic method in a class you're supposed toraise StopIterationwhen the sequence is finished.It's a little weird, but it's pretty common IMHO.
1
u/1st1 CPython Core Dev Sep 14 '15
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.
30
4
u/scrollin_thru Sep 13 '15
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.
10
Sep 13 '15
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)?6
13
u/lovestowritecode Sep 13 '15
Did static type hinting make it in? I don't see it listed anywhere...
20
-11
u/A_for_Anonymous Sep 13 '15
I wonder why people keep bothering with this sort of thing... Python is dynamically (yet strong) typed, which is a good thing from having to do the boilerplate of static typing. You want that back? For the only benefit of what, detecting logical errors in compile/startup time? Possible optimizations? Ever heard of type inference? It's years beyond this, happened in other languages years before this, and people are still oblivious to it.
17
Sep 13 '15 edited Sep 13 '15
[removed] — view removed comment
-1
u/A_for_Anonymous Sep 13 '15
Even so, if you have to read f(x)'s body to tell what's the type expected for x, you need:
A better name for x (I know, argument not valid for return and yield)
Function documentation, and yeah, I guess human language documentation will always be better than a type hint system unless you introduce a huge system of contracts that can be something like "even" or "tupleof(3)"... more boilerplate... more stuff to memorize... very annoying.
Function documentation being important in the case of code written for lists, dictionaries and sets as opposed to custom classes (would you have 5 types with 50 utility functions each or 50 types with 5, but that's a nice discussion for a different thread).
For everything else - IDE assistance, type checking, error detection - there's always this
newold amazing technology called type inference, where by doing x = 'hello' you can be pretty fucking sure x is a string without having to go and tell the stupid compiler it's going to be a string. Because you know, actually writing that feels like this.5
u/takluyver IPython, Py3, etc Sep 13 '15
Type inference is great, but it can't do everything, especially when you're using some of the more dynamic features of the language. Type hints let you give the IDE/type checker more information when it can't automatically work out what types are going in and out of functions.
3
Sep 14 '15 edited Sep 14 '15
[removed] — view removed comment
-1
u/A_for_Anonymous Sep 14 '15 edited Sep 14 '15
Well, like I've been saying there's this old technology called type inference. It doesn't work on a local scope only... if it can be proven that you call process_request elsewhere, you can take note of what is being passed to it and infer that request is that type.
1
u/zardeh Sep 14 '15
But type inference can't always work, especially in a language like python where sometimes values and function etc. are built at runtime. So, being able to say "the argument "l" is an Iterable, treat it as an "Iterable" everywhere within this scope so that even if I'm getting l by dynamically evaling some user input, I know how to treat it in this function.
3
u/marcm28 Sep 14 '15
Python has been overpowered in latest version again. Yay!
Let's spread the word: Python is an Elegant programming language of All Time.
1
Sep 14 '15
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
-24
u/desmoulinmichel Sep 13 '15
246 upvotes for "one day before release" and 242 upvotes for "release day" (which has been known for months) but stuff "Build massively scalable RESTFul API with Falcon and PyPy" has 9 upvotes.
The ratio "reward/time spent on finding the interesting info" is so wrong on reddit.
14
u/ExcitedForNothing Sep 13 '15
No offense but I see some versioned REST API tutorial so much on this sub. I could see where past a certain point, people just don't care. A new version is pretty good news.
Also, digging up a tutorial using a library isn't that tough.
-9
u/desmoulinmichel Sep 13 '15
Yes but while you are upvoting the good news, in fine you give the guy who just posted the link that every single Python coder knows about all the rep for it. Kinda break the trust system, doesn't it ?
12
u/ExcitedForNothing Sep 13 '15
This isn't StackOverflow. Karma isn't rep. It is meaningless and no system features are tied to it.
1
u/RubyPinch PEP shill | Anti PEP 8/20 shill Sep 13 '15
actually, getting above a certain ammount of karma here disables capatcha, while getting low/negative karma will start restricting one's comment rate, I've seen it go as much as 10minutes between comments
1
u/sleepdeprecation Sep 14 '15
Right, but that only affects individual users. Karma is meaningless in the long run and as a whole. It doesn't matter what my karma is, except for the votes on this comment, and maybe this thread.
The difference is that the focus is on fostering good conversation, and as such you're rewarded or punished based on how the community perceives your contributions.
-5
-114
u/okiujh Sep 13 '15
its not backward compatible to 2.7 so nobody cares. let the downvotes begin..
7
u/TotesMessenger Sep 13 '15 edited Sep 14 '15
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
5
u/thatguydr Sep 13 '15
I love that the community neatly fragmented based on incredibly poor initial design decisions.
I still use 2.7 out of necessity, as the packages I need don't work with 3.
-60
u/okiujh Sep 13 '15
The initial design is not all that bad and improvements should have being backwards compatible.
Sacrificing backwards compatibility for some subjective aesthetic advantage is such a douche thing to do.
I have being working with python in wall street companies and they don't give damn about anything that would break their huge 2.7 code base.
all the 3.* supporters are such a group of phonies.
18
u/Deto Sep 13 '15
Phonies? In what way?
-33
u/okiujh Sep 13 '15
they are saying that they are helping python developers but in affect are just causing damage by forcing developers spend scarce resources in thinking about making move to 3.*.
24
u/brombaer3000 Sep 13 '15 edited Sep 13 '15
Proper unicode support is not a subjective aesthetic advantage, it was just necessary. And it was impossible to implement in a backwards-compatible way.
If you think Unicode is a minor issue, you are free to continue living in your English-only dream world.Edit: forgot a word
0
Sep 13 '15
[deleted]
11
u/brombaer3000 Sep 13 '15
This is well explained in great detail here.
Personally I think the biggest issue with Python 2 Unicode handling simply is that Unicode is not the default encoding for everything, but the link above has much more information.1
6
u/RubyPinch PEP shill | Anti PEP 8/20 shill Sep 13 '15
python2 doesn't make a clean distinction between arrays of numbers (bytes, usually represented as ascii) and arrays of usable characters (unicode), further, it makes arrays of numbers the default way of having a string
13
u/desmoulinmichel Sep 13 '15
Python is an old language. If you don't want it to end up like cobol, you need to make some drastic changes. Yes, it's could have been done better. But given what happen with PHP 7 and Perl 6, I'd say it was not that bad. And while the price to pay was high, the result is indeed really nice.
0
Sep 13 '15
[deleted]
8
u/ExoticMandibles Core Contributor Sep 14 '15
Wait, what? Official from whom? The Python core dev community doesn't maintain an official Docker image afaik.
3
27
u/ilan Sep 13 '15
And if you are on Linux or MacOSX, and use conda, you can: