12 ms·
Python 3.5.0
- ricw 11y agoBy far the most exciting news here, to me, is PEP 484 typing module. Typing support would eliminate one of pythons biggest weaknesses. Furthermore, having it optional means it can remain as easy play and prototype with while becoming "more professional." The other features are all well rounded, with co-routines having quite some potential, though I'd have to play around with them first to assess. Now if everything would please start moving on to Python 3 pretty please ;).
- bpicolo 11y agoI like the thought of coroutines, but it's definitely been especially slow for the ecosystem to adapt to asyncio so far. (And for good reason. It has new syntax that doesn't play well with non-asyncio). Adding even more syntax for the same things may slow down adoption more? Admittedly, it's much better syntax. The optional typing is a tricky subject. I'll have to wait until there are tools actually using it to see. One of my biggest hesitances with it is that until runtime checking or really good static analysis exists, annotating things incorrectly can be too easy. I am cautiously optimistic though. The theory is fantastic, just have to wait for the follow through. The best way to sort-of statically type things right now(imo) is through namedtuples (which I make use of heavily for lightweight, strict datatypes) Formatting for bytes and bytearray is actually one I run into a ton trying to port py2 code to py3. Pretty excited about that.
- rspeer 11y agoPyCharm already takes advantage of optional typing using Python 3 annotations. The typing module will allow more types to be expressed, and I assume they'll update to take advantage of annotations that involve the typing module.
- 1st1 11y agoFWIW Tornado already supports the new syntax: http://tornado.readthedocs.org/en/latest/guide/coroutines.html#python-3-5-async-and-await http://tornado.readthedocs.org/en/latest/guide/coroutines.ht...
- gh02t 11y agoHeh, for me it's the matrix multiply operator. Such a minor addition will make for a pretty big improvement to my day-to-day coding experience.
- vegabook 11y agoAgreed but does this apply in Numpy as well? Will Python matrix multiplications just work on lists of lists in which case they're much slower? Sorry just asking from a 2.7 holdout here as this might cause me to move.
- gh02t 11y agoDoubt it. The @ symbol isn't implemented by default. It's just available as a syntactic element primarily for NumPy to use, though other libraries are free to use it as well.
- dalke 11y agoI want to see it used for an XML library, since I think node@"name" is a more succinct, and domain-appropriate equivalent for node.attrib.get("name").
- gh02t 11y agoI have kind of mixed feelings. The biggest argument against that PEP was that people would use it for things that are very unlike matrix multiplication, which can be confusing. I can kind of see the point there, but on the other hand the @ symbol really is natural for things like what you suggest.
- dalke 11y agoUnusual operator overloading isn't that common in Python, though '%' for string processing is a big and primordial exception. Of the packages I know which use it, only PyParsing uses overloading for something non-analogous to the normal meanings. I tried hard to think of ways to (ab)use '@', and this XML example and perhaps some sort of messaging API were the only two I could come up with where there was a natural domain-specific mapping. One of the advantages of keeping '@' at the same precedence level and ordering as '*', '/', '%', and '//' is that it doesn't really offer much in the way of new use. If someone uses '@' for something very unlike matrix multiplication, then they could already use any of the other 4 symbols that way. So I don't think @ ends up as an attractive nuisance.
- 6502nerdface 11y ago> PEP 484 typing module Looking forward to this as well. So far the only static analysis tool I'm aware of that makes use of the PEP 484 framework is mypy [1] -- does anybody happen to know of other tools in the works? [1] http://mypy-lang.org/ http://mypy-lang.org/
- gsnedders 11y agoI know PyCharms is working on using them for its type-hints as well as offering better auto-completion options.
- techdragon 11y agoAnd this is why I paid for Pycharm. (and why their change in pricing model is so damn awkard, I both love them and hate them at the moment.)
- mands 11y agoYep - can't wait until Python3 is the norm. Feels like such a step back when I have to use a Python 2.x codebase - so many little annoyances.
- techdragon 11y agoJoin us in the future! I made python 3 a 'production readiness requirement' at the start of this year. My two biggest Python3 complaints have stopped being 'something doesn't work' to 1: Pyston is targeting Python 2 and 2: PyPy doesn't care enough about Python 3 ( I mean seriously... PyPy + AsyncIO = EPIC )
- TheCondor 11y agoPypy is accepting donations for 3. I encourage everyone that is interested to chip in a few bucks
- zo1 11y ago"Now if everything would please start moving on to Python 3 pretty please ;)." Unfortunately, not always an option. Or rather, it is, but would require an immense amount of effort. Not to mention, the client wouldn't be too happy with the increase in bugs. Working on a legacy C++/Python implementation stuck with 2.5. It's not as bad as it sounds, really. You learn to improvise, and work on python 2.7/3+ in off-hours.
- deleted 11y ago[deleted]
- wheaties 11y agoDoes this mean that asyncio will be deprecated as there's now 2 ways to accomplish much of the same thing or do they truly have different semantics?
- 1st1 11y agoProbably you're confused by PEP 492. It's not replacing asyncio, in fact it's about adding new language features to make programming with asyncio (and other frameworks, such as Tornado) more convenient.
- task_queue 11y agoIt complements asyncio. In particular, you'd probably want to use asyncio's event loop to drive your coroutines.
- baxter001 11y agoThe scandir update also changes the underlying implementation of os.walk giving loads of production apps a huge speed increase by making use of additional data returned by the os calls.
- lamby 11y agoCould os.walk have been changed "under the hood" without a PEP? eg. using — just for example — fast_walk_in_c in _os.so (I understand that adding os.scandir might require a PEP)
- masklinn 11y agoIn theory, but because the change was possibly complex and could be useful if available separately, one of the first thing a core member recommended was to iterate the poc as a genuine package and provide an API to the underlying system (which is now scandir). https://mail.python.org/pipermail/python-ideas/2012-November/017784.html https://mail.python.org/pipermail/python-ideas/2012-November... is the original proposal on -ideas.
- haypo 11y agoNo, a PEP was required because there was a lot of discussion on the API, and also non trivial choices on the implementation (pure C? pure Python? C+Python?). To have an idea of the amount of discussion, read the "Rejected ideas" of the PEP: https://www.python.org/dev/peps/pep-0471/#rejected-ideas https://www.python.org/dev/peps/pep-0471/#rejected-ideas
- lamby 11y agoWhy would changing the underlying workings of os.walk require a PEP?
- pdknsk 11y agoPEP 0448 in addition to already implemented PEP 3132 make it very tempting to switch. If PEP 0448 had unpacking in comprehensions I'd switch. (Doesn't seem be a follow-up PEP just for that functionality yet.) https://www.python.org/dev/peps/pep-0448/ https://www.python.org/dev/peps/pep-0448/ https://www.python.org/dev/peps/pep-3132/ https://www.python.org/dev/peps/pep-3132/ I'd be really nice to use this. >>> [*range(i) for i in range(5)] Instead of this monstrosity right now. >>> [x for y in (range(i) for i in range(5)) for x in y] Python 2.7 has some minor features that 3 dropped unfortunately, which still makes me hesitate. Such as filter keeping the type. In 3 it returns an iterator. >>> filter(lambda x: x in 'ABC', 'ABCDEFA') 'ABCA' Or this mostly cosmetic feature. >>> filter(lambda x: x[0] > x[1], ((1, 2), (4, 3))) >>> filter(lambda (x, y): x > y, ((1, 2), (4, 3))) # equivalent, error in 3 Also dropped. (It's slower than using the dedicated base64 module though.) >>>'Python'.encode('base64') 'UHl0aG9u\n' Also, I like print.
- poooogles 11y agoAre you tied to 2.7 for any other libraries or are these minor bits all that's keeping you from switching? If so I'd really recommend you just try python3 for a week, and have a play with some of the new features/functionality and the minor points will soon melt away.
- dalke 11y agoOther options for your first case are: >>> sum((range(i) for i in range(5)), []) [0, 0, 1, 0, 1, 2, 0, 1, 2, 3] and >>> import itertools >>> list(itertools.chain.from_iterable(range(i) for i in range(5))) [0, 0, 1, 0, 1, 2, 0, 1, 2, 3] "filter keeping the type". That was only true for some types. Python 2.7's filter does not maintain the set type: >>> filter(lambda x: x in 'ABC', {'A','B','C','D','E','F','A'}) ['A', 'C', 'B'] Regarding the cosmetic feature, that's a consequence of PEP 3113 -- Removal of Tuple Parameter Unpacking , https://www.python.org/dev/peps/pep-3113/ https://www.python.org/dev/peps/pep-3113/ , which also applies to functions. I use 's.encode("hex")' often. I realize why hex/base64 are gone, but it's so short and easy in Python 2.7.
- Veedrac 11y ago
- 1st1 11y agoWhat's New in 3.5 document: https://docs.python.org/3.5/whatsnew/3.5.html https://docs.python.org/3.5/whatsnew/3.5.html
- bbrazil 11y agoPEP 0475 makes me happy, I've had to workaround interrupted syscalls a few times.
- cmacke 11y agoIt's about time I switched to Python 3.
- ceronman 11y agoSo far, this is my favorite 3.x release. Typing annotations, async/await, unpacking generalizations. Lots of cool new features. Too bad that PEP0498[1] didn't make it in this release, we'll have to wait for 3.6. [1] https://www.python.org/dev/peps/pep-0498/ https://www.python.org/dev/peps/pep-0498/
- redsymbol 11y agoPython 3 keeps getting better and better. I've been writing more code in Python 3 than 2 for about three years now, and I absolutely love it. When I have to write code in 2.7 now, it feels like shifting from fifth gear down to second.
- rizwank 11y agoIs Py3 ready for prime time? Do all the right libraries have support now?
- vikp 11y agoYes -- I write ~95% of my python code in 3, and scrapy is the only library I commonly use that doesn't support it. Here's a listing of package compatibility: http://py3readiness.org/ http://py3readiness.org/.
- kodr 11y agoand the other one: https://python3wos.appspot.com/ https://python3wos.appspot.com/
- nickysielicki 11y agoIt's been ready for prime time for the past 3 years.
- deleted 11y ago[deleted]
- jay_kyburz 11y agoUnfortunately I'm stuck on 2.7 until Google updates App Engine
- wyldfire 11y agoMost of the time I find it pretty easy to make it compatible with both 2.7 and 3.4. Usually just a few "from __future__ import print_function" and a few other tips. If your codebase is large, it can feel daunting, but it's not usually that bad.
- incepted 11y agoAnd yet, Python 2 usage is still strong while Python 3 adoption has actually slowed down, and at this rate, it will probably stop being used completely while Python 2 continues to live on: https://www.reddit.com/r/programming/comments/3k9yif/larry_wall_presents_perl_6_xpost_rperl/cuwi9zy https://www.reddit.com/r/programming/comments/3k9yif/larry_w...
- scrollaway 11y agoWhat's your point? You do have a point, right? Coming in to a thread about a python release and trying to stir up controversy? Or are you just doing it for kicks?
- iso8859-1 11y agoHis point seems obvious to me: he thinks Python 3 is not worth migrating to, because Python 2 will always have more users. But it disregards that Python 3 may be more comfortable. And it assumes that the Python 3 user base will shrink in the future.
- aldanor 11y agoTrolls are trolls...
- viraptor 11y ago> Python 2 usage is still strong while Python 3 adoption has actually slowed down Hypothesis: distributions started installing python3 by default now, so people don't have to download it separately anymore. Python 2 downloads will stay at the same level as they were and actually 2.6 will go up as it's not available in supported distributions anymore. This is strangely opposite trend to actual adoption.
- collinmanderson 11y agoPython 3 usage doubled in the last year: https://caremad.io/2015/04/a-year-of-pypi-downloads/ https://caremad.io/2015/04/a-year-of-pypi-downloads/
- sandGorgon 11y agoQuestion - is there any web/api framework that leverages asyncio ? This implicitly also means first class DB/ORM support. Flask, sqlalchemy ,etc seem to be using gevent and py 2.7.
- e12e 11y agoI'm not sure, but perhaps aiohttp[1] fits the bill? Not sure if there's a "full" framework that does everything, but take a look at the simple benchmark code: https://github.com/klen/py-frameworks-bench/blob/develop/frameworks/aiohttp/app.py https://github.com/klen/py-frameworks-bench/blob/develop/fra... (from: http://klen.github.io/py-frameworks-bench/ http://klen.github.io/py-frameworks-bench/) [1] http://aiohttp.readthedocs.org/en/stable/ http://aiohttp.readthedocs.org/en/stable/
- sandGorgon 11y agoin this case, how are most of you guys writing code with asyncio ? or is there any code being written at all. Right now, it seems to me that Python 3.5 is not ready for adoption since it is not usable with any framework at all. I mean, I really want to use asyncio, but 99% of python mindshare is around SqlAlchemy, Bottle, Flask, Django and Cherrypy. and I cant use it with any of them. aiohttp looks cool, but I would much rather use one of the above for now. Anybody know why are none of these framework maintainers leveraging this stuff ?
- deleted 11y ago
- jeo1234 11y agoVery pleased to see PEP 465. In many ways I think python is one of the most exciting languages in terms of where it is going and what it is trying to do.
- wpietri 11y agoI've recently joined a Python project, my first time working with the language. We're currently using Python 2.7. How do experienced Pythonistas decide if/when to upgrade to 3.x? I figured it was a no brainer given that it has been 7 years with a number of big releases, but Flask's warning on this topic put me off: http://flask.pocoo.org/docs/0.10/python3/ http://flask.pocoo.org/docs/0.10/python3/
- detaro 11y agoIMHO the only reason to use 2.x for new projects is if a necessary dependency doesn't exist for 3 yet. Sadly the situation for using asyncio for web was not that great last I checked, because that would be a strong incentive.
- bpicolo 11y agoThose flask docs look out of date. I don't think you'll hit those troubles in python 3 anymore. It's imo a very mature ecosystem now.
- viraptor 11y agoThat's very out of date going by: "Python 3 currently has less than 1% of the users of Python 2 going by PyPI download stats." The web ui download starts stopped being updated in 2013 if I remember correctly and api was disabled shortly after due to migration to CDN. So these stats are ~2 years out of date.
- techdragon 11y agoUse it by default. If something doesnt work and you cant or dont want to make it work yourself, then fall back and use 2.7.10 P.S. That flask warning is definitely very out of date. I used Flask with Python3 quite happily, literally this week.
- 88e282102ae2e5b 11y agoI like the "use Python 3 by default, and only use Python 2 if you have mandatory dependencies that aren't 3.x compatible" rule.
- deleted 11y ago[deleted]
- gwpolenti 11y agoCould someone explain how to properly install Python 3.5.0 on Ubuntu so that it replaces the system's default Python 3.4.0 as the new default? Installing is the easy part, but I haven't figured out how to also make sure all the libraries that come with Python are also replaced with the 3.5 versions. Thanks!
- pixelmonkey 11y agoI really enjoy using pyenv these days. https://github.com/yyuu/pyenv https://github.com/yyuu/pyenv In that case, `pyenv install 3.5.0` and then `pyenv shell 3.5.0` or `pyenv global 3.5.0` to switch which Python gets used. With pyenv's virtualenv plugin, you can also get rid of the need to use virtualenvwrapper for managing dependencies.
- cname 11y agoI think the only correct way to do this is via 'apt-get upgrade'. In other words, you probably don't want to replace the system Python manually, because a lot of utilities depend on it, and you might bork your system. Using virtualenv is the generally-recommended way to run a different version.
- jessaustin 11y agoI've often wondered why utilities that are particular about python versions don't just specify which version they want in the hashbang line. Actually it seems some utilities do exactly that: $ head -1 /usr/bin/lsb_release #! /usr/bin/python3 -Es Obviously, all utilities should do this, and should probably be more specific than that. Distros could have a tool to patch this automatically, and then they wouldn't break when the user chooses to upgrade system python.
- slgeorge 11y agoYou probably don't want to do this. For stability it's best to keep the system managed through packages from the standard repositories. If you install things that are not from the repositories the packaging system won't be able to track dependencies - it will have bad information about some capabilities as some items won't have been installed using the packaging system. Overwriting official system libraries is a common cause of problems. It's best to only upgrade something when the repository for your release makes it available: it pays to be conservative about the repositories you use, sticking to the standard ones and thinking very carefully about adding any others (e.g PPA's). If you want 'newer' versions of frameworks/libraries for development then you're better off installing them away from the main system - traditionally that is /usr/local, or using a partitioning system such as chroot. For Python specifically there's a really nice option of use venv/virtualenv.
- mixmastamyk 11y agoThere are some other nice nuggets in there. * The new subprocess.run() function provides a streamlined way to run subprocesses. Yeah! I've implemented that function a dozen times in projects, I suppose because it was too trivial to put on pypi. * collections.OrderedDict is now implemented in C, which makes it 4 to 100 times faster. Nice, I use this one relatively often.
- jcadam 11y agoI'd love to use Python 3. Alas, I work in the defense industry and am working on a new development project in Python 2.6. Why? Because that's the version that's already installed on the client's systems, and getting anything new installed is such a nightmare of Vogon-esque policies and procedures that I've learned not to even ask. I'm constantly having to hack around bugs in ancient versions of libraries that have been fixed years ago for the same reason. I have a feeling the slow adoption rate of python 3 is not due to developers "rejecting" it.
- mixmastamyk 11y agoIf you're already working around bugs you could create your own venv with a later version. Easier to ask forgiveness than permission.
- techdragon 11y agoNot in the defence industry.
- scrollaway 11y agoSome industries will be stuck with old versions of just about any language, no matter what. GP actually said he's stuck on 2.6, which means he can't even use 2.7.
- _spoonman 11y agoI work in defense. Software approval is for major releases, so he I don't see why he couldn't use 2.7. If he wants to go to 3, that's when he'd have to get approval.
- engi_nerd 11y agoI work in the defense industry. Sometimes it is indeed easier to ask for forgiveness than permission, but you must be very careful. Obviously anything that violates any NDAs or security agreements is not to be pushed at all, but I've had no problems writing and running Python and MATLAB programs. Point is, defense industry doesn't automatically equal a locked down environment.
- dancsi 11y agoI am impressed that it upgraded cleanly over my previous installation of Python 3.5 release candidate.
- kozukumi 11y agoThe new Windows installer is nice. It has needed updating for a long time so glad to see it get some love finally.
- ctolsen 11y agoAwaiting an official release (and my PR being merged), I made a Docker image which is simply an upgrade of the official one: https://hub.docker.com/r/ctolsen/python/ https://hub.docker.com/r/ctolsen/python/ Also, pytest users might want to use their dev version for now until they fix a 3.5 issue.
- dkarapetyan 11y agoPython somehow always manages to miss the mark. The new co-routine stuff is a good example. Who can explain to me how I return more than once from the same co-routine? That is what a co-routine is after all no?
- viraptor 11y agoCheck any tutorial about it or even the relevant pep. It's explained in many places. In short: def some_co(): yield 2 yield 3
- dkarapetyan 11y agoHmm, It is a SyntaxError to have yield or yield from expressions in an async function. That's what I mean when I say it misses the mark. There are now two ways of doing the same thing and one of them is more powerful than the other. Using generators I can use both `yield` and `yield from` but if I use what they're calling co-routines then I can only use `yield from`. I see no value in the new syntax. So an async function is not really a co-routine. It is a regular function that gets to use `await` and that's it. Calling it a co-routine is misleading and confusing.
- eevee 11y agoThe new coroutine stuff is really just syntactic sugar for "yield from", which has been around for a few versions now (and in turn is little more than syntactic sugar for "yield"ing repeatedly). But you don't return more than once from a coroutine. You can suspend it as often as you like, and that's what "await" does.
- kayman 11y agoMy experience: I've tried Python 3 and enjoy it very much. A few things drove me nuts at first, trying to figure out why syntax that worked in Python2 is not longer working in Python3. But a little bit of googling and I was on my way with Python3. I have a project that I started a long time ago in Python2 using web.py. I tried to migrate to Python3, but unfortunately, web.py is not supported. I know Flask has python3 support and I could migrate to that but I'm not ready to move my whole code base over yet. From someone who tried to migrate to Python3 with no compelling reason to, hit a roadblock, I immediately shelved the problem till later as I'm not missing anything critical from Python3 to warrant the effort. I wonder how many other projects go through this? Especially much larger, more complex code bases.
- giancarlostoro 11y agoBy the way have you tried out CherryPy? Another web library to consider when dealing with Python 3 projects.
- thomasahle 11y agoI love all the performance improvements to the standard library. That Serhiy Storchaka has made an impressive amount of contributions, a doesn't seem to be working for anyone?
- mark-r 11y agoWorth it just for isclose.
- wiz21c 11y agoGreat! 134 comments so far and only 1 or 2 about "Python 3 will never prevail", "Python 2 is better" and the usual rant. Things are getting better !