14 ms·
What’s New In Python 3.6
- orf 10y agoHmm, the documentation seems to be updated to show 3.6 in the dropdown but it's not on the release page yet.
- iguessthislldo 10y agoIt's only a release candidate for right now.
- herge 10y agoI do not know which feature I will miss the most whenever I have to use older versions of python, either the f-string interpolation or the underscores in numeric literals.
- underyx 10y agoIt seems to be just 3.6.0 RC1 actually: https://mail.python.org/pipermail/python-announce-list/2016-December/011396.html https://mail.python.org/pipermail/python-announce-list/2016-...
- devy 10y agoNote Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.6 moves towards release, so it’s worth checking back even after reading earlier versions. Although this document is dated today, but it bears the above note right below editors. Also according to PEP 464's Python 3.6 release schedule, Python 3.6.0 final was scheduled on 2016-12-16. So the title should be changed to "Python 3.6 release candidate 1 released"
- deleted 10y ago[deleted]
- wbond 10y agoMy favorite bits include UTF-8 encoding support for Windows filesystems and console, scrypt, and OpenSSL 1.1.0 support.
- vosper 10y agoMaybe this should be obvious, but I don't have a computer to hand to try and figure it out: In the example for f-string interpolation, why does value have to be declared like this: value = decimal.Decimal("12.34567") Why wouldn't this work? value = 12.34567
- orf 10y agoFloats != decimals, and it's good practice to use Decimal I think.
- renzon 10y agoIt's not good practice. You must use Decimal when precision is important. Example: when dealing with currency, so arithmetic operations don't create or miss cents.
- webmaven 10y agoBecause that gives you a Float, not a Decimal.
- gizmo385 10y agoDoesn't seem very Pythonic to me...
- teilo 10y agoEvery type-inference language I am aware of assumes that anything that looks like a float is a float. It would be un-pythonic to assume that everything that looks like a float is a decimal. Imagine having to cast every damn float to a float.
- dragonwriter 10y agoSince when does an exact decimal literal "look like a float" more than it looks like a decimal?
- jscheel 10y agoGreat, another release that python devs can refuse to use.
- jscheel 10y agoOuch, harsh downvoting :) Guess the 2.7-4-life folks are a little sensitive. Anyways, it's great to see python continue to move forward. I just wish more devs would admit that python 2 is not the future and move on to 3.
- SixSigma 10y ago> On Linux, os.urandom() now blocks until the system urandom entropy pool is initialized to increase the security I prefer to use the phrase "less insecure" than "more secure".
- module0000 10y agoThe dict shrinkage(25% less!) in memory is pretty sweet! I'm not sure how many of you abuse dicts to hold [just about] everything, but this is a big boost for those of us that do.
- virgil_disgr4ce 10y ago"Dict shrinkage"
- Alex3917 10y agoI've been trying to break this habit and get into using namedtuples, but the problem is I still need to look up the API every time I need to use them.
- erokar 10y agoBesides immutability, what are the advantages of using namedtuples instead of dicts?
- burntsushi 10y ago- A clear single point of truth describing your data. - Probably more memory efficient.
- i80and 10y agoWe can test memory usage in CPython (3.5)! >>> import collections >>> import sys >>> class A: ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> class B: ... __slots__ = ('x', 'y') ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> C = collections.namedtuple('C', ('x', 'y')) >>> a = A(1, 1) >>> b = B(1, 1) >>> c = C(1, 1) >>> d = {'x': 1, 'y': 1} >>> sys.getsizeof(a) + sys.getsizeof(a.__dict__) # Plain object 344 >>> sys.getsizeof(b) + sys.getsizeof(b.__slots__) # Plain object with slots 120 >>> sys.getsizeof(c) # Named Tuple 64 >>> sys.getsizeof(d) # Dict 288 EDIT: Fixed a slew of measurement issues EDIT2: Included size of __slots__ tuple
- pbiggar 10y agoI wonder if there's a way to make all strings be format strings?
- _quick_q 10y agoWhy would you want that?
- pbiggar 10y agoI like strings to be interpolated by default, and that's one of the most annoying things about python.
- kazagistar 10y agoI'm disappointed in the interpolated strings. We finally get them, but its already behind the curve compared to Scala or C#, due to not being lazy and allowing context sensitive string interpolation. The better design binds the values to the string, but does not interpolate into a string type fully. Then, the resulting object can be passed to a consumer like an SQL engine (and appropriately escaped) or an internationalization library (and swapped out for a translated string before interpolation). I mean, I appreciate what they did, but it seems like missing a massive opportunity to provide a linguistic building block for library authors.
- mixmastamyk 10y agoThese ideas were discussed at length, but it was ultimately decided to keep things simple. Perhaps the mechanism can be extended in the future? In the meantime the 90% case is supported.
- renzon 10y agoFor i18n you can still do the same of _('your template here {foo}'), where _ is you gettext[1]. And once it has a lazy version, you will be covered. [1] https://docs.python.org/2/library/gettext.html#gnu-gettext-api https://docs.python.org/2/library/gettext.html#gnu-gettext-a...
- masklinn 10y agoThat doesn't work, unless `_` is a gettext overlay which goes and reaches into its caller stackframe and performs string interpolation itself. Otherwise you mean that you can "still do the same of" _('your template here {foo}').format(foo=foo) which is a step down from f'your template here {foo}'
- RodericDay 10y agoLove interpolation, still shaking my head @ the typing syntax primes: List[int] = [] captain: str # Note: no initial value! class Starship: stats: Dict[str, int] = {}
- _quick_q 10y agoCould you expand? This looks similar to how it is done in Rust.
- RodericDay 10y agoIt looks very ugly to me, particularly the trying to reverse the original mistakes behind `int`, `list`, `dict` into `Int`, `List`, `Dict`. If you want to fix that, you fix that first, then apply it to a subsequent patch like this one. Additionally, I think Rust community, since its inception, embraced the goal of paying any up-front costs required for introspection. Meanwhile, the Python community seems to be tearing between those who want syntactical beauty and one-way-to-do-it, and those who are running big production systems using IDEs like PyCharm and wanting to benefit them. I'd prefer it if Python somehow warned people developing gigantic systems that maybe it's time to use a different language, instead of deforming Python to suit the people already running gigantic systems in a language unsuited to it.
- orf 10y agoType hints are completely optional. Nobody is getting torn, and both use cases are equally valid.
- RodericDay 10y agosee: "only one way to do it" Well, I'm not going to stop using Python or anything. I just think they're bad and ugly and I'm sad that more and more I'll open the source code of some library I'm using and find those "hints" littered everywhere. I would plea that people reconsider their inclusion, but it seems like that ship set sail.
- d_theorist 10y agoThis will probably be an unpopular thing to say, and I understand that people have different opinions and preferences on this question. However, for me, every time I see one of these Python 3 releases it makes me appreciate Go's model of language maintenance and development more and more. Compare the last few major Go releases to the last few Py3 releases. Go has so much more discipline about when it's appropriate to add things to the language. Most of Go's changes are confined to bug fixes, performance improvements, and toolchain improvements. By comparison, it seems like Python is on a runaway train of core-language additions.
- amq 10y agoCompare even PHP.
- paulddraper 10y agoIn that comparison, Go is a homeless (or maybe "minimalist") guy with a shopping cart.
- goatlover 10y agoThere probably is a good balance between adding features and being conservative. I feel like Go is too minimalistic, making you have to write boilerplate code other languages like Python have nice abstractions for, while C++ is the opposite. But also, Python has been around a lot longer, so we'll see if Go keeps it's minimalistic philosophy over another decade.
- baq 10y agothis only proves the point that there's room for both. i like new features and can't wait for both f-strings and type annotations.
- slyzmud 10y agoAlthought I really like python and prefert it to go. I think what you say has a lot of sense. I would like to know why you are being downvoted. It's a valid opinion expressed in a nice way.
- gigatexal 10y agoIt's really neat to see async coming to things like generators and comprehensions. Looking forward to trying it out.
- fogleman 10y agoI'll say it. Python 2: Stability. Python 3: Feature creep. I've been doing a lot of Go lately and hugely appreciate the minimal syntax and orthogonal features. Seems like the opposite is happening not just in Python but many languages.
- zzleeper 10y agoFor me, it's Python 2: weird quirks (unicode support sucks, I have to do from future import for a lot of things, etc.). On the other hand, Python 3 fixes many of these things, and even others that I didn't realize could be better thought out (such as names of some stdlib functions, etc.)
- MollyR 10y agoI used to feel that way,but all my day jobs are python 2. They never to seem to want to budget in time to do an upgrade to python 3. It's been frustrating. Lately I've been so frustrated I've actually been researching new languages with better performance, because that's a MUCH easy sales pitch to the business managers.
- goatlover 10y agoJulia :-)
- alexchamberlain 10y agoPyPy3?
- p10_user 10y agoThe time it would take to port code from 2 to 3 would likely be less than the time it would take to port to another language. And using the scipy stack makes numerical computing incredibly fast (fast enough for me considering it takes me longer to figure out how to analyze the results), though your use case may differ.
- goatlover 10y agoAre you the same person who advocates switching to Go over Python 3 in every single Python thread? Not everyone prefers the minimal approach, particularly in a dynamic, higher level scripting language, where ease of use trumps other considerations. Go and Python occupy different niches, for the most part. So the design considerations for Go are naturally different than those for Python.
- jjwiseman 10y ago"The default console on Windows will now accept all Unicode characters and provide correctly read str objects to Python code. sys.stdin, sys.stdout and sys.stderr now default to utf-8 encoding." Thank god.
- fermigier 10y agoFirst of all, congratulation and a huge thank you to the core python development team. I know some of them have expressed frustration (or more negative feelings) at the way some people have been reacting to their work. As the Python ecosystem is progressively moving to Python 3 (according to some stats, the tipping point should be reached in a few months), I hope that this trend of excellent Python 3 releases will continue.
- lima 10y agoJust as an anecdote: I haven't heard _any_ criticism about Python 3 outside of the Hacker News community. In Germany, everyone loves it, if only for the improved Unicode handling.
- danso 10y agoGiven that the HN community might represent a decent chunk of the overall Python-using community, I wouldn't interpret that as HN being whiners for the sake of whining. For starters, Armin Ronacher has written thorough essays on his dislikes. He comments on HN but his influence is obviously much bigger as a Python developer (Flask, etc). In academia/science, maybe people aren't ripping on 3.x explicitly, But that's because they have the ability to control the work environment and stick with 2.x. They don't rip on 3.x because it's non-existent as far as they are concerned. Example: http://people.cs.umass.edu/~sheldon/teaching/cs335/ http://people.cs.umass.edu/~sheldon/teaching/cs335/ > Programming assignments will use Python, NumPy, and SciPy. The required Python environment is the Anaconda 4.1.1 distribution of Python 2.7. We will not help grade or debug work unless you are working in this environment.
- geezerjay 10y ago> I haven't heard _any_ criticism about Python 3 outside of the Hacker News community. That only means you don't participate in any other online community that discusses Python 3 besides Hacker News. For instance, the Python2 Vs Python3 migration issues are widely known even for those who never written a single LoC in Python.
- Animats 10y agoWell, the "type annotation" system, where you get to type variables but the types don't do anything, was expanded again. It doesn't improve safety. It doesn't improve performance. The hand-waving argument is "Just as for function annotations, the Python interpreter does not attach any particular meaning to variable annotations and only stores them in the __annotations__ attribute of a class or module. In contrast to variable declarations in statically typed languages, the goal of annotation syntax is to provide an easy way to specify structured type metadata for third party tools and libraries via the abstract syntax tree and the __annotations__ attribute." Whatever that's supposed to mean. I still suspect that was put in to screw over PyPy. If the type information was enforced, PyPy could use it to generate hard-typed code and improve performance. CPython, on the other hand, still represents everything as CObject objects in C. Type checking adds run-time overhead.
- jammycakes 10y agoThe Python interpreter itself may not do anything with the annotations, but static type checkers and linters can, and they will give you the safety that you need. The annotations also allow the development of better IntelliSense-like tools.
- baq 10y agothis comment reads much better if you replace Python with Javascript and PyPy with V8 or whatever, especially with today's Typescript announcement. additionally try using mypy-lang some. it's great.
- crystalPalace 10y agoReally happy to see the secrets module being added to the standard library. Now to make sure every Python developer knows of its existence.
- tedmiston 10y ago> PEP 515: Underscores in Numeric Literals > PEP 515 adds the ability to use underscores in numeric literals for improved readability. For example: >>> >>> 1_000_000_000_000_000 1000000000000000 A small touch but this is quite nice.