Announcement

Collapse
No announcement yet.

Python 3 Is Close To Becoming The Default In Fedora 22

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Togga
    replied
    Originally posted by TheBlackCat View Post
    Or you could just use list comprehensions.


    Just things I have encountered:
    1. Division is handled sanely without having to import from __future__
    2. No more long vs. int
    3. keyword-only arguments
    4. a, b, *c = (1, 2, 3, 4, 5) (this may be even more flexible in 3.5)
    5. Ranges are lazy (but still indexable), saving memory
    6. Dict methods use views, saving memory
    7. super() works
    8. __pycache__ and supporting multiple python version .pyc files and .so files
    9. yield from
    10. 0100 != 64
    11. statistics module
    12. Pool, popen, and assertRaises context managers
    13. pool.startmap
    14. unittest.assertWarns and unittest.assertCountEqual
    15. high-performance decimals


    Stuff coming in 3.5:
    1. math.nan and math.inf
    2. type annotations

    I see no justification for python3 here. A number of bugs (?) and annoyances that should (and is?) fixed or implemented in python2? There were really never any justifications for non-backwards-compatible changes to Python2.
    For statistics, I recommend scipy instead (or R).

    Leave a comment:


  • TheBlackCat
    replied
    Originally posted by nanonyme View Post
    And Python3 does change many API's for which bytestrings make more sense to use unicode objects because consistency beat practicality in Guido's mind at the time.
    Such as? Lots of APIs use bytes where they make sense, and there will always be disagreements about whether bytes are better for a particular API or unicode is better, so judgement calls have to be made. I know there was some cases where there was the opposite issue, where frome a purely technical standpoint bytes may have been more correct, but it was felt that unicode was more convenient for users (practicality beats purity), but that is almost the opposite of what you are talking about.

    Whatever your feeling about particular APIs, at the end of the day, the big advantage in this regard is that in Python 3 (but not Python 2), unicode is unicode and bytes are bytes. They are clearly, cleanly, and explicitly distinguished, and when you try to mix them you need to be explicit about it, without all the unexpected breakage in obscure encoding-specific corner cases.
    Last edited by TheBlackCat; 23 January 2015, 02:24 PM.

    Leave a comment:


  • nanonyme
    replied
    Originally posted by TheBlackCat View Post
    The core language does, as a separate type. The problem is that lots of modules, particularly third-party ones, explode when given unicode because python 2 can behave unpredictably or raise an exception when particular unicode is combined with strings in particular ways.


    Yes, so much fun putting that in every single module you write and enter it every single time you start the python REPL (ipython can help with the latter if you manually configure it to import at startup, although that slows startup times).
    Well, the big change between Python2 and Python3 is no more implicit encoding and decoding between unicode objects and bytestrings. Just that Python2 strings are bytestrings while Python3 strings are unicode objects is honestly smaller. And Python3 does change many API's for which bytestrings make more sense to use unicode objects because consistency beat practicality in Guido's mind at the time. It is unfortunate these incorrect changes are so hard to revert without a Python4 which is not going to happen in foreseen future

    Leave a comment:


  • TheBlackCat
    replied
    Originally posted by nanonyme View Post
    Python2 supports utf-8 just fine.
    The core language does, as a separate type. The problem is that lots of modules, particularly third-party ones, explode when given unicode because python 2 can behave unpredictably or raise an exception when particular unicode is combined with strings in particular ways.

    Originally posted by nanonyme View Post
    Print function is available in Python2 with a future import.
    Yes, so much fun putting that in every single module you write and enter it every single time you start the python REPL (ipython can help with the latter if you manually configure it to import at startup, although that slows startup times).

    Leave a comment:


  • TheBlackCat
    replied
    Originally posted by Togga View Post
    And the fact that python3 got worse, especially when used interactively. In python2 you have a nice distinction for instance between "map" and "imap", in python3 you need to write "list(map(fn,lst))" to see the result on the prompt or get a list.
    Or you could just use list comprehensions.

    Originally posted by Togga View Post
    I can see no reason to switch to Python3. Can you? (besides "it's new").
    Just things I have encountered:
    1. Division is handled sanely without having to import from __future__
    2. No more long vs. int
    3. keyword-only arguments
    4. a, b, *c = (1, 2, 3, 4, 5) (this may be even more flexible in 3.5)
    5. Ranges are lazy (but still indexable), saving memory
    6. Dict methods use views, saving memory
    7. super() works
    8. __pycache__ and supporting multiple python version .pyc files and .so files
    9. yield from
    10. 0100 != 64
    11. statistics module
    12. Pool, popen, and assertRaises context managers
    13. pool.startmap
    14. unittest.assertWarns and unittest.assertCountEqual
    15. high-performance decimals


    Stuff coming in 3.5:
    1. math.nan and math.inf
    2. type annotations

    Leave a comment:


  • nanonyme
    replied
    Originally posted by Cyber Killer View Post
    I've been working as a software tester on a couple of py2 based projects, they were webapps using django, twisted, etc... a typical testcase was: input japanese characters into a textfield, submit the form, so it gets saved into the db... and watch as the whole thing falls apart, when the devs fix this particular form, repeat with the next one cause it's going to be broken in the same way.

    Even in python shell scripts it's more or less ok with utf8 on Linux if you write the needed charset header in the file and you can use nonwestern chars, but as soon as you try it on windows, it breaks.

    From my experience py2 and unicode don't mix. Period.
    No, the problem is that Windows and utf-8 don't mix. The literally only options there are utf-16 (ish) and 8-bit locale-specific encodings. Python3 just tries to hide this reality from you slightly better

    Leave a comment:


  • Cyber Killer
    replied
    Originally posted by nanonyme View Post
    Python2 supports utf-8 just fine.
    I've been working as a software tester on a couple of py2 based projects, they were webapps using django, twisted, etc... a typical testcase was: input japanese characters into a textfield, submit the form, so it gets saved into the db... and watch as the whole thing falls apart, when the devs fix this particular form, repeat with the next one cause it's going to be broken in the same way.

    Even in python shell scripts it's more or less ok with utf8 on Linux if you write the needed charset header in the file and you can use nonwestern chars, but as soon as you try it on windows, it breaks.

    From my experience py2 and unicode don't mix. Period.

    Leave a comment:


  • nanonyme
    replied
    Originally posted by Cyber Killer View Post
    Of course I do:
    - utf8 - finally, maybe in the English speaking world this isn't a big deal, but in every eastern European country, that has it's own special characters in the alphabet, this is a killer feature - getting py2 to correctly support non-western characters is a major headache
    - more functions instead of statements (with print being the biggest deal) make the syntax a lot more clear to anybody coming from other languages

    note: I generally write in whichever language gets me what I want in the easiest and fastest way, so I'm not a python fan any more than I'm a fan of bash, php, ruby, lua, etc... but I find py3 a lot more convenient than py2, for my use when I want to write something in python
    Python2 supports utf-8 just fine. Bigger issue is eg Windows still doesn't use it pretty much anywhere. Print function is available in Python2 with a future import.
    Last edited by nanonyme; 23 January 2015, 04:37 AM.

    Leave a comment:


  • slavek
    replied
    Originally posted by phoronix View Post
    Phoronix: Python 3 Is Close To Becoming The Default In Fedora 22

    For Python stakeholders using Fedora, the Fedora 22 release is preparing to ship Python 3 as the one and only Python implementation on the installation media...

    http://www.phoronix.com/scan.php?pag...ython-3-Status

    Thanks for writing a nice article. Please note that as I've written in the sum-up mail, we most likely won't achieve completely Python2-free LiveCD, just mostly. Might be worth mentioning in the article, since it seems to suggest otherwise

    Leave a comment:


  • Cyber Killer
    replied
    Originally posted by Togga View Post
    I can see no reason to switch to Python3. Can you? (besides "it's new").
    Of course I do:
    - utf8 - finally, maybe in the English speaking world this isn't a big deal, but in every eastern European country, that has it's own special characters in the alphabet, this is a killer feature - getting py2 to correctly support non-western characters is a major headache
    - more functions instead of statements (with print being the biggest deal) make the syntax a lot more clear to anybody coming from other languages

    note: I generally write in whichever language gets me what I want in the easiest and fastest way, so I'm not a python fan any more than I'm a fan of bash, php, ruby, lua, etc... but I find py3 a lot more convenient than py2, for my use when I want to write something in python

    Leave a comment:

Working...
X