{"id":1493,"date":"2021-10-14T19:08:39","date_gmt":"2021-10-14T07:08:39","guid":{"rendered":"http:\/\/p-s.co.nz\/wordpress\/?p=1493"},"modified":"2022-04-20T18:08:58","modified_gmt":"2022-04-20T06:08:58","slug":"python-versions-what-they-add","status":"publish","type":"post","link":"http:\/\/p-s.co.nz\/wordpress\/python-versions-what-they-add\/","title":{"rendered":"Python Versions &#8211; What They Add"},"content":{"rendered":"\n<p>This is a personal list of what I really liked (and disliked) about each release of Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3.11<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>19% speed improvement<\/li><li>more informative KeyError handling<\/li><li>TOML batteries included<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.10<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Better messages for syntax errors e.g. <code>\"SyntaxError: { was never closed\"<\/code> for line 1 where the curly brace started rather than <code>\"SyntaxError: '{' was never closed\"<\/code> for line 3 which was an innocent line<\/li><li>Note &#8211; Structural Pattern Matching should be considered more of an anti-feature given its problems and its limited benefits for a dynamically typed language like Python<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.9<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>String methods removesuffix and removeprefix (NOT same as rstrip() as that works on the letters). Note &#8211; absence of underscores in method names<\/li><li>Union operator for dicts (new dict which is an update of the first by the second) e.g. <code>up_to_date_dict = orig_dict | fresh_dict<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.8<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>f-strings support e.g. <code>f\"{var=}\"<\/code><\/li><li>walrus operator <code>:=<\/code> (an antifeature with costs that outweigh benefits)<\/li><li>positional-only parameters (so can change names without breaking code) &#8211; like extending list comprehensions to cover dictionaries, sets, and tuples it completes the coverage as you&#8217;d expect<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.7<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Nothing<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.6<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>f-strings (massive)<\/li><li>Underscores in numbers e.g. 3_500_000 &#8211; as a data guy this is huge<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a personal list of what I really liked (and disliked) about each release of Python. 3.11 19% speed improvement more informative KeyError handling TOML batteries included 3.10 Better messages for syntax errors e.g. &#8220;SyntaxError: { was never closed&#8221; &hellip; <a href=\"http:\/\/p-s.co.nz\/wordpress\/python-versions-what-they-add\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3],"tags":[21,26,18,15,25],"class_list":["post-1493","post","type-post","status-publish","format-standard","hentry","category-programming","category-python","tag-code","tag-pattern-matching","tag-programming","tag-python","tag-python3"],"_links":{"self":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/1493"}],"collection":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/comments?post=1493"}],"version-history":[{"count":26,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/1493\/revisions"}],"predecessor-version":[{"id":1523,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/1493\/revisions\/1523"}],"wp:attachment":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/media?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/categories?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/tags?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}