14 ms·
Frankly, I still haven't seen a single reason to switch to Python3 beyond the fact that the original authors have gotten bored of providing security and bugfix
by Figs 9y ago
Frankly, I still haven't seen a single reason to switch to Python3 beyond the fact that the original authors have gotten bored of providing security and bugfix updates and will stop in 2020. That's it.
The only thing in the last decade or so of Python3's existence that even got me slightly interested in using it was asyncio, and after looking into it a bit, it frankly seems like more trouble than its worth.
I know Python 2.7 extremely well. It works perfectly fine for just about everything I use it for. It's STABLE. For the tasks I use it for, it runs faster than Python3... (Not that performance is my greatest concern when using Python.) So, please tell me -- why on earth is it a good thing that people are trying to kill off Python2? What exactly makes Python 3.6 a "decent step up" from 2.7? I'm still at the point of thinking, as you said, that Python3 is a bad thing.
- Sir_Cmpwn 9y agoBecause Python 2 is an objectively worse language. Do we have to pretend this is still an argument? Do we have to rehash this? The reasons are well known. Do your damn research.
- brians 9y agoThe change to string handling justifies it for me. Writing `u’foo’` everywhere is a pain, and the rest of the 2.7 model is extraordinarily prone to runtime errors. With 3.6, I don’t have those problems.
- pc2g4d 9y agoYeah, I was pretty much sold on Python 3 when I stopped having to use the `codecs` module to read my files and when it would strictly enforce the separation between `bytes` and `str`, rather than having to manually track what sort of sequence I was dealing with.
- dbcurtis 9y agoYes, yes. My Python life is mostly about impelemnting odd protocols with Twisted. Will probably get serious about asyncio soon, but I have a lot of historical Twisted to deal with ATM. I've noticed that the "Who cares about Python 3" types are not the people working on the kinds of problems I am. So my conclussion is that for many kinds of problems the benefits of Python 2 are kind of meh, so people stay in their comfort zone. For some kinds of problems, Python 3 is a huge, huge win over Python 2. Whether or not someone is a Python 3 advocate says more about the kinds of problems they work on than anything else.
- fredley 9y agoYes, and while performance on some tasks has gotten worse, on others it has got much better - JSON serialisation in particular, which was huge for us. Python 3.7 will be faster again in many areas.
- kajecounterhack 9y ago+1 Just because we learned to work around unicode issues doesn't mean they're not completely bonkers in 2.7
- vetinari 9y agoMost people didn't learn to work around unicode issues during the 2.7 time frame. Many third party modules tended to explode spectacularly with encode/decode errors, when they were fed non-ascii strings, when used by people who write using all these funny characters. Just the correct handling of strings in Python 3 alone is a hell of a reason to switch to it.
- bonesss 9y agoLet's not forget the joy of third party libraries that wouldn't fail, but rather silently convert, your data because they had hidden ascii asumptions...
- __d 9y agoI have a contrary anecdote: for the sorts of work I do, having to distinguish between strings and bytes makes using Python3 more difficult, and more prone to errors. I mostly deal with network protocols, lots of numeric content, and scarcely any non-English text. But I appreciate other people have different needs.
- joshuamorton 9y agoI feel like the answer to this is "then use bytes everywhere". Why doesn't that work?
- orf 9y agoThat's akin to saying: > For the sorts of work I do, having to distinguish between lists and dictionaries makes using Python 3 more difficult and more prone to errors. I mostly deal with lists, and scaresely any dictionaries. Just use bytes where appropriate.
- xapata 9y agoUntil you've used them for a while, you won't believe how pleasant f-strings are. It's worth the upgrade.
- SatvikBeri 9y agoOptional type annotations did it for me - I don't usually use them, but I find them very helpful on a few types of tasks.
- takluyver 9y agoFor anything non-trivial, 95% of the value is in the library ecosystem. So long as most prominent libraries kept releasing new features for Python 2 and 3, there's inevitably not a big pull factor to upgrade. That's changing as a number of major libraries start to make releases that require Python 3. From a library maintainer POV, I do want to use Python 3. There's no one killer feature, but rather a bunch of small ones, like more specific exception classes (FileNotFoundError etc.). But if you want to keep using Python 2.7, no-one will take it away from you.
- brownbat 9y ago> For anything non-trivial, 95% of the value is in the library ecosystem. Toy programs and rapid scripting and prototyping... FWIW I love my trivial use of python.
- nas 9y ago> Frankly, I still haven't seen a single reason to switch to Python3 beyond the fact that the original authors have gotten bored of providing security and bugfix updates and will stop in 2020. That's it. It seems pretty clear now that 3rd party library developers are going to stop releasing packages that support 2.x and target only 3.x. Isn't that a bigger problem for Python 2.7 hold outs? Originally, I was not super excited about Python 3. I liked "print" as a keyword. I liked the space efficiency and speed of latin-1 strings by default. I did a lot of network protocol stuff and bytes() was a pain to use. I knew how to use the 'u' prefix to get unicode when I needed. However, after using Python 3 for a few years now, I find Python 2 clumsy. Print as a function is better. Unicode works better. The implementation is just as fast or faster than Python 2 and getting faster every release. If you tried Python 3 a few releases ago, you should give it another go. It has matured a lot.
- Figs 9y ago> Isn't that a bigger problem for Python 2.7 hold outs? Yes, but it seemed like libraries (such as NumPy here) were mainly switching because of the EOL of Python2 rather than for any actual benefit provided by Python3. I've considered that as more of "Python 3 is a bad thing" by splitting the ecosystem further, and creating additional churn and rework of existing projects. Thus my question of why people seem to think this is a good thing now -- i.e. what has changed in Python 3.6 that they're happy to do this now when they were pissed off about it a couple years ago? I've gotten a couple interesting responses here, and I hope for more. I wasn't really aware of f-strings -- that does seems like a nice-to-have feature -- and I wasn't aware of improved JSON serialization performance either. > If you tried Python 3 a few releases ago, you should give it another go. It has matured a lot. I may do that.
- skierscott 9y ago> what has changed in Python 3.6 that they're happy to do this now when they were pissed off about it a couple years ago? Most of mine have to do with developer productovity and I didn’t find until Python 3.5. – @, the matmul operator – fstrings (f”{foo}”) – parameter typing (foo: int = 0) which has exciting work with Cython – other async features. I forget what library it was (tensorflow?) but for Python 3 it had better async support
- PunchTornado 9y agoBecause python3 is the new version.
- theon144 9y agohttps://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-python-3/ https://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-p... is a fairly good summary. There are loads and loads of syntax improvements (I personally love the new unpacking), new features, and other enhancements. Sure, you can continue using Python 2, and it's going to work for you. I guess you can also keep using Windows XP (no reason not to use it beyond the fact that Microsoft has gotten bored of providing security and bugfixes), and code using your PS/2 keyboard...
- Aardwolf 9y agoUSB for keyboards is slower (noticable for some types of gaming) and does not support over 6-key rollover. So PS/2 is superior (for keyboard, not mouse) and not dead. Ever noticed around 2010 motherboards stopped shipping with PS/2, but today most for desktops come with a single PS/2 port again?
- pwdisswordfish 9y ago> and code using your PS/2 keyboard... That's not even a hipster thing, it's quite mainstream with gaming keyboards...
- _wwz4 9y agowhy on earth is it a good thing that people are trying to kill off Python2? Because the community is fragmented and that weakens language adoption, productivity, and enjoyment. The 2-3 schism in Python has been a pain to deal with for years. I use Python casually here and there, but I'm so sick of trying to do something quickly in Python and finding out that I'm on a machine that only has 2 but the module I need is only for 3 or having the bulk of my app written in 3 but the only version of a module I need is for 2. Same goes for examples you find on the Internet to do a particular thing. Ooops, it's 2.x syntax/modules so you have to fix it up for 3. Ooops, it's 3 syntax/modules so you have to fix it up for 2. For the good of any computer language, old versions need to eventually die off.
- cpncrunch 9y ago>For the good of any computer language, old versions need to eventually die off. I would say instead: for any good computer language, new versions need to retain compatibility with old versions. Every single system I run has python 2.7 (including my brand new Macbook running latest OS X). Luckily I don't need numpy, and I can probably do without python at all if I have to. Compare to perl: I can run old perl scripts on basically any system without having to worry about it breaking. I do all of my server scripting in perl for this reason.
- cyphar 9y agoPerl6 is incompatible with Perl5, so they're also going through a similarly painful transition. Everyone waxes lyrical about how Python 2.x was "good enough and why would you change it", but there were several things in Python 2.x that were objectively awful (unicode was broken, iterator variables can leak to the outer scope, division of integers producing integers, xrange, raw_input, mixed indentation "working", etc). And while no single issue alone would justify Python 3.x, the combination of all of these issues as well as some other semantic problems justified the need for Python 3. Of course, that being said, Python 3 also had some issues that it took several versions to iron out.
- cpncrunch 9y ago
- zenbot 9y agoNick Coghlan has written on this extensively: http://ncoghlan-devs-python-notes.readthedocs.io/en/latest/python3/questions_and_answers.html#out-of-the-box-why-is-python-3-better-than-python-2 http://ncoghlan-devs-python-notes.readthedocs.io/en/latest/p...
- mattbillenstein 9y agoIt's a bunch of smaller things, but I think the major one is the new compact dict implementation. Using less memory is a good thing and you basically get it for free using Python3.
- fro0116 9y agoJust adding my random piece of anecdata: docker-compose uses Python2 and has encoding issues on Windows that have no real workarounds other than upgrading to Python3: https://github.com/docker/compose/issues/2775 https://github.com/docker/compose/issues/2775
- brownbat 9y agoThis is an ancient argument because no one can convince you that you need 3 for your use case. All I can do is say why I like it, and list reasons that probably don't apply to you or you would have switched already. For example, print and division made more sense to me in 3, judging from friends who taught 2 and said those were always sticky for some students in every class. Intuitive lowers the barrier to entry. (But 2 is probably more intuitive to you because it's second nature to you by now.) Unicode--when I would test some tiny scripts with Chinese characters or weird ciphers--was pretty easy out of the box in 3. On systems that only support 2 I find myself slipping in basically a 'from future import all the things.' These are admittedly mostly cosmetics. But cosmetics matter for noobs like I was, or maybe still am. I guess 3 also fixed ambiguity in corner cases for error handling? Never came up for me so I don't know much about that one. You probably just don't have those use cases? Two people could use distinct subsets of python and neither is using it wrong. Meaning... there could be reasons many of us want 3 that simply don't apply to you. Which sucks, because you get hit with switching costs to help the rest of us. I think that's the recipe for an endless debate with two reasonable sides. I will say py2 was already fragmented without 3. PaiMei only ran on... 2.4 maybe? You'd find weird projects that you liked that would then get abandoned. Suddenly you're shimming them all or running four versions. I think 3 woke people up to this as a problem--by making it much harder to patch and way more universal. That made the project more conscious about future and backwards compatibility. Those dividends will only be seen over time. I hope they vest but can't prove how or if they have. I hope this is helpful... Just know that I'm not saying you're wrong to want to use something that works for you. Switching costs are a real thing, I know it sucks to feel dragged along. But py3 is a lot better for me and others, possibly because we're using the language for different things.
- amorphid 9y agoIt's pretty hard to make a case for transitioning from something that works pretty well to a new thing in general. The nicer the old thing is, and the wider it's been adopted, the harder the sell. That's just the way it is. Too look at it a different way... If I see the benefit of & would like to make a change, actually making the change competes with all of my priorities. I'm under the impression that Python is used by many people who use reliable things with APIs that don't change often (I mainly of thinking of Bash & some Posix OS). I can see why they wouldn't be fans of making changes. Personally I like using newer things, all other things being equal. That's mostly because it's easier to chat about recent stuff with people learning the same lessons I'm learning. Almost every time I ask a C/Bash/*NIX question on a Stack Exchange site, the question gets marked as a duplicate, links to a question with answers I had already, but failed to understand. That happens much less when inquiring on newer topics.
- jlarocco 9y agoNobody is forcing you to stop using Python 2.7, but the rest of the world is getting over it and moving on. I'm sorry if that seems mean, but in the grand scheme of things the differences between 2 and 3 are pretty trivial, and most people still complaining about this are just being stubborn. I refuse to believe somebody can know Python 2.7 "extremely well" but then also need more than ten years to learn the few areas where Python 3 is different.
- stordoff 9y agoFor me, it was Unicode - it was much easier to move to Python3 than trying to retrofit my Python2 code base to use Unicode.
- foxylad 9y agoAs a 2.7 user, I drool over f strings.
- Avshalom 9y agoWhat was your reason for changing from 2.6 to 2.7?
- humanjvm 9y agoThere were no breaking changes in the language.
- ubernostrum 9y agoFrankly, I still haven't seen a single reason to switch to Python3 This typically means one of two things: 1. You've never really looked at the features added in the Python 3.x release series, or 2. You develop abandonware which plans never to upgrade any part of its platform ever, for any reason, and so no conceivable new feature would be sufficient to convince you to do an upgrade. At this point (1) is untenable because of how many people have written about the useful things available in 3.x, and (2) is disingenuous (but there are still plenty of people who use "don't see a reason to upgrade" as an excuse for "I always planned to abandon this"). Just in case you're one of the people in (1), here you go: https://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-python-3/ https://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-p...
- bandrami 9y agoThe irony of calling software that still runs decades after it was written "abandonware" is probably lost here, but I enjoyed that.
- takeda 9y agoYou should give Python 3.6 a try and you will see. There are many minor improvements and new functionality that working with it is so much enjoyable and make code more readable and shorter. I got to a point where it feels like a chore whenever I have to use Python 2.7.
- traverseda 9y agof strings. https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatte...
- SmirkingRevenge 9y agoThere's all the pain of python 2's string/byte handling... is it a byte str? Or unicode code points? Python 2 likes to keep you guessing, and that's not a good thing. If you haven't felt the pain here, there's a good chance your stuff is subtly broken in ways you may not be aware of.
- dotancohen 9y ago> What exactly makes Python 3.6 a "decent step up" from 2.7? Proper handling of Unicode, and more sensible distinction between bytes and characters. Seriously, Python 3 has done that _so well_ that I wish other languages would take notice.
- Rotareti 9y ago> What exactly makes Python 3.6 a "decent step up" from 2.7? The language and the standard lib improved a lot. There are so many improvements, it would be impossible to list them all after so many years of progress... Just to name a few of the bigger improvements, that I have discovered recently: * The typing module lets you add type annotations to your code and write code like this: class User(NamedTuple): id: int name: str age: int def remove_user(u: User) -> None: # ... fred = User(123, 'fred', 42) # ... remove_user(fred) * F-strigs are awesome: file_path = f'{base_dir}/{user_name}/{latest_dir}' * I think asyncio and the async/await syntax are great. * The refactoring of the subprocess module: subprocess.run(my_cmd) * The documentation of the standard lib improved a lot, if you ask me. This is just off the top of my head... But really, it's the overall improvement of the language and the standard lib that make the difference, not just the big features.
- StreamBright 9y agoMoreover there were some packages even last year that were simply broken with Python 3.x. What am I supposed to do if I have to deliver something to a client and the Python 3 version of my stack is broken? I do not necessarily have the time to debug the issue and fix it and it is much easier to switch to 2.7 and just continue working on the business problem. Software guys (especially guys working on programming languages and environments, tools) have to understand that providing a broken alternative is not an real option at all. Anyways, I haven't been running into issues with Python 3 recently and I use it as much as I can.
- cturner 9y agoThe killer feature of Python3 is string representation. IO work in python2 (e.g. network programming) was made more complicated by the evolutionary mess of python2's string design. If you want to get strong at network programming without spinning up on all the complex topics in async io (coroutines, futures, etc), you may like my networking system: github.com/solent/solent-eng It is designed to allow the programmer to reason about exactly what the process is doing, rather than to hide things away. The docs are not in great shape at the moment. Good starting points: the telnet client (in tools) and the snake game (demo package). This was originally in python2. I moved because of subtle improvements in python3 packages over python2. But once I appreciated the string changes, I wished I had moved much earlier.
- drej 9y agoMy personal reason that may be relevant for quite a few people. Not quantifying that any further, just my 2c. https://news.ycombinator.com/item?id=12930793 https://news.ycombinator.com/item?id=12930793
- belorn 9y ago> it runs faster than Python3 Generally speaking, Python 3 is actually faster now. I am a bit surprised that no one else has commented on this. There was a talk about performance recently (https://www.youtube.com/watch?v=d65dCD3VH9Q https://www.youtube.com/watch?v=d65dCD3VH9Q). To sum it up, some parts are slower and other parts are faster, and the reasons depend on two questions: 1: Is it using a lot of small ints? Python 3 changed int from being small int to long int, and for work which deals with massive amount of ints this will result in a slow down. If for some reason you want to use a pure Python implementation of AES rather than using hardware acceleration (generally builtin to the CPU) or a C implementation, or the one built in the linux kernel, then you will hit the performance test that get the biggest negative difference between python 2.7 and master. Then there is numpy which uses C modules that can happy do things as small ints. 2: Bytes -> Unicode. Libraries that are Unicode unaware will run faster than libraries that are Unicode aware. The feature to understand that "ö" is a Swedish letter and not several characters does cost some CPU time. For parsing where per character manipulation is relevant (like say HTML), such parsing will be a bit slower in python 3. Practically everything else is faster now in python 3.
- gspetr 9y agoSurprised nobody posted this yet: https://speakerdeck.com/pyconslides/python-3-dot-3-trust-me-its-better-than-python-2-dot-7-by-dr-brett-cannon https://speakerdeck.com/pyconslides/python-3-dot-3-trust-me-... It's a presentation by core developer Brett Cannon which explains what's better about Python 3. The list is quite long for an HN comment, so I'm not going to repeat it here. Now it's pretty dated as there had been more things added like async, so Python 3 is even better now.
- opencl 9y agoPython2's unicode support is kind of an error-prone mess and that was what prompted the decision to make 3 a breaking change in the first place. It is much harder to shoot yourself in the foot with text handling in 3 IMO, though it's certainly still not perfect. Of course lots of people think their programs with broken unicode handling work fine until someone passes them data in any language other than English.
- OOPMan 9y agoYou must not have looked very hard then. Python 2.7 has just about the worst unicode handling of ANY language I've ever used. Plenty of otherwise crappy languages (Java, JavaScript, etc) managed to make one right choice when they decided that strings are always unicode and bytes are a different data type entirely. Also, the asyncio implementation in Python 3, while a bit complicated, is on the whole very nice, providing a lot of flexibility. Long story short, if you still think Python 3.6 is "bad" in this day and age then you need to move on to another language.
- peterbengkui 9y agoIf you ever need to deal with encoding, you will very soon know why my friend. I've hated Python3 just as much but reality left me with no choice. It's time to say goodbye sooner rather than later.