4 ms·
I'm doing ML in Python 2 and I can't see a single reason to move to Python 3. Every article is about strings, but in fact I needed to work with Unicode once (mo
by Dzugaru 10y ago
I'm doing ML in Python 2 and I can't see a single reason to move to Python 3. Every article is about strings, but in fact I needed to work with Unicode once (mostly doing computer vision tasks, but once trained a RNN on a book in my native language just for fun) - and I don't remember ANY problem with it in Python 2.
So, why should I bother migrating? I moved to C# 7 instantly and never looked back, for example, because it has tons of stuff. But the only thing I hear about Python 3 is "it's so much better!!!111" and "strings, you need it".
- msl09 10y agoIf you are not using strings then very few things are different between Python 3 and 2 so the cost of change to a more maintained interpreter is even smaller for you. The only real problem you might have is having some library that doesn't have Python 3 support. Also since you are dealing with ml I must warn you that the developers already committed to not support Python 2 in the future, not sure about numpy though.
- throwawayish 10y agoPython 3 has mostly more stuff than Python 2 in the stdlib, some Syntax improvements, most of which are supported by Python 2.7 backports as well. So yes, arguably there are entire classes of problems were one doesn't need to care about differences between Python 2 and 3. But there are also many classes of problems where the differences matter very much.
- einarfd 10y agoThe reason that there is a lot of articles about strings is because there is a vocal minority that really hates the Python 3 string changes, and they where the most contentious changes in the language. Current Python 3 has changed a lot since the first versions of Python 3, and there is a whole host of improvements that makes it superior. None of them earth shaking but a host of them worth it. Python 3.6 was just released, and I would recommend having a look at its whats new document, to get a feel for what has changed since 2.7.
- detaro 10y agoAll the articles are about strings since those are the most fought-about change, and the thing you'll likely have to deal with the most when porting. Python3 IMHO has no single "killer feature", but especially with recent versions has a lot of very nice things that add up, which isn't talked about in the prominent articles because it is not controversial. (Well, the async stuff kind of is, since it's a feature many people want, but it also is quite confusing)
- throwawayish 10y agoActually I don't believe that "those are the most fought-about change", I think it's a very loud minority. In more personal circles I don't know anyone who knows anyone who ... It might be though that the new text model faces more resistance in English speaking countries, because ASCIIbytes is obviously less troublesome there, so people might not see the need for Unicode.
- _Wintermute 10y agoThis is probably why the scientific computing community is very slow in adopting python3, there are simply very few benefits apart from the threat of 2020.
- andreareina 10y agoPython 3 fixes the issue where variables in a comprehension "leak" to the surrounding scope. Python 2: x = 'hello' [x*x for x in range(5)] #=> [0, 1, 4, 9, 16] x #=> 4 Python 3: x = 'hello' [x*x for x in range(5)] #=> [0, 1, 4, 9, 16] x #=> 'hello' Python 3 has improved destructuring support Python 2: a, *b = [1, 2, 3] #=> Syntax error Python 3: a, *b = [1, 2, 3] a #=> 1 b #=> [2, 3] Type annotations[1] are nice not because they enable typechecking, but because they tell me what the function expects. Maybe it's just the kind of programming I do, but I use a bunch of libraries with functions that take a class or function as input, except half the time they want the name to the thing instead of the actual reference. [1] https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/
- daveguy 10y ago> I can't see a single reason to move to Python 3. If you are doing any sort of scientific computing there is no compelling reason to move to Python 3. The nuances that you have to grok with the Py3 str are the same nuances you would have to grok about using the Unicode implementation of Py2 instead of the default encoding in Py2. They just made the default more complicated if you are working with data. Now they require you to add 'b' to every damn thing and they have the arrogance to claim this is the "right way" to do it. Like someone else said earlier -- computer science strings are a sequence of bytes. If you want to encode and decode from byte strings use another type. They should make the default bytes and print utf-8 interpretation. Oh, but then they would have Py2 and they would realize what an authoritarian goose chase Py3 has been.
- nharada 10y agoAs an ML person, I appreciate the infix matrix multiply operator (@). Using np.dot is cumbersome and makes formulas difficult to read. In fact, until this feature was added, I considered the readability of vector and matrix formulae one of the strongest arguments of using Matlab over Python for prototyping. https://www.python.org/dev/peps/pep-0465/#executive-summary https://www.python.org/dev/peps/pep-0465/#executive-summary
- teilo 10y agoI use Python for a significant amount of data munging. Dictionary comprehensions alone was worth the switch for me. When I started, pandas did not exist, so I had to develop everything from scratch.