Znaczące zmiany wprowadzone w każdej wersji Pythona 3

hejto.pl

Każda z wersji Pythona wprowadzała wiele zmian i ulepszeń - poniżej subiektywnie selektywna lista najważniejszych zmian wprowadzonych do każdej większej wersji Pythona 3:


Python 3.0 (2008-12-03):


  • print statement replaced with a print() function

  • dict.iterkeys(), dict.iteritems(), and dict.itervalues() removed

  • Python 2’s xrange() is Python 3’s range(); Python 2’s range() is no more

  • Python 2’s str is Python 3’s bytes; Python 2’s unicode is Python 3’s str

  • The default Python source encoding is now UTF-8

  • urllib2 module split into urllib.request and urllib.error modules

  • urlparse module renamed to urllib.parse

  • urllib module split into urllib.parse, urllib.request, and urllib.error modules


Python 3.1 (2009-06-26):


  • The fields in strings formatted with str.format() can now omit numbering in order to be automatically numbered, as in 'Sir {} of {}'.format('Gallahad', 'Camelot')

  • round(x, n) now returns an integer if x is an integer

  • collections module: Counter and OrderedDict added


Python 3.2 (2011-02-20)


  • New modules: argparse, concurrent.futures, html, and sysconfig

  • .pyc files are now stored in __pycache__/ directories

  • datetime module: timezone added


Python 3.3 (2012-09-29)


  • New modules: faulthandler, ipaddress, lzma, unittest.mock, and venv

  • Support for implicit namespace packages (directories without an __init__.py) added

  • datetime module: New datetime methods: timestamp(), strftime(), and astimezone()


Python 3.4 (2014-03-17)


  • New modules: asyncio, ensurepip, enum, pathlib, selectors, statistics, and tracemalloc

  • http.server command-line interface: --bind option added


Python 3.5 (2015-09-13)


  • Coroutine functions (async def), awaitable objects (await and __await__()), asynchronous iteration (async for, __aiter__(), and __anext__()), and asynchronous context managers (async with, __aenter__(), and __aexit__()) added

  • Multiple * and/or ** unpackings can now be used in a single function call

  • New modules: typing and zipapp

  • Various additions & improvements to the asyncio module


Python 3.6 (2016-12-23)


  • Formatted string literals (“f-strings”)

  • Variables can now be annotated by following the name of the variable with a colon and the annotation

  • Underscores can now be used in numeric literals

  • await and yield can now be used in the same function, thereby enabling asynchronous generators

  • async for can now be used in list, set, & dict comprehensions and in generator expressions

  • await expressions can now be used in any comprehension

  • **kwargs now preserves insertion order

  • dicts are now implemented in such a way that they preserve insertion order

  • Various additions & improvements to the asyncio module


Python 3.7 (2018-06-27)


  • dicts are now guaranteed to preserve insertion order

  • async and await are now reserved keywords

  • New modules: contextvars, dataclasses, importlib.resources


Python 3.8 (2019-10-14)


  • Assignment expressions: := (the “walrus operator”) can now be used to assign a value to a variable in the middle of an expression

  • Function parameters can now be made positional-only by placing a / after them in the argument list


Python 3.9 (2020-10-05)


  • dicts can now be merged & updated using the | and |= operators

  • New modules: graphlib and zoneinfo

  • asyncio module: to_thread() added

  • Removed: asyncio.Task.current_task() and asyncio.Task.all_tasks() (deprecated since Python 3.7); use asyncio.current_task() and asyncio.all_tasks() instead


Python 3.10 (2021-10-04)


  • Pattern matching with match/case syntax

  • Common syntax errors now have better error messages


Python 3.11 (2022-10-03)


  • Exception groups

  • Traceback messages now highlight the exact expression that caused the error

  • New modules: tomllib and wsgiref.types


#technologia #programowanie #python

hejto.pl

Komentarze (12)

koszotorobur

Do Pythona 3.10 i 3.11 są oficjalne grafiki z największymi zmianami wprowadzonymi w tych wersjach.

0f47b89c-2301-4d40-91f7-f2331d09273c
dc4c06ea-0694-42f9-8f8f-08f0694b4dc3
GetBetterSoon

@koszotorobur spoko podsumowanie

koszotorobur

@GetBetterSoon - większość (jak nie każda) z tych rzeczy znalazła się na powyższej liście dlatego, że pozytywnie wpłynęła na moją pracę z Pythonem.

Tank1991

@koszotorobur zazdro, no to mi tylko typing spadł z nieba, argparse jest w pytke, a tam gdzie chciałbym użyć async to na złość programy mam na windoze.

no i od biedy dataclasy ale to głownie przez typing.


a i OrderedDict to był w p2

L4RU55O

Piękny wpis, nic nie rozumiem

56b290c8-a7ae-425f-8a7c-998e06c245f4
L4RU55O

@koszotorobur  Talentu nie mam do programowania ale będę miał co poczytać do snu. Dzięki.

koszotorobur

@L4RU55O - mi się też kiedyś tak wydawało - po początkowych porażkach się zaparłem i okazało się, że to jest do ogarnięcia. Ale nie ma sensu nikogo przekonywać

@GetBetterSoon w innym moim wpisie powiedział, że:

 Na pythoninstitute.org jest tez zacny kurs.

L4RU55O

@koszotorobur Ogólnie to odbiłem się na studiach od C a potem już C++ mnie dobił i nawet nie chodziłem na zajęcia bo to była czarna magia.


Teraz jak brat coś programuje to ogólnie rozumiem co do mnie mówi i kolejne kroki programu, wiem niby w którą stronę to idzie ale jakbym miał coś samemu napisać to umarł w butach.

sierzant_armii_12_malp

Najważniejszego brakuje: w końcu zaczęli tę kobyłę optymalizować, z wersji na wersję generalnie przyspiesza.

koszotorobur

@sierzant_armii_12_malp - fakt - optymalizacje są zauważalne - migrowałem aplikację co codziennie obrabia podobne ilości danych z 3.9 na 3.11 i jest z 15% szybciej gdy infrastruktura i kod się nie zmieniły - widzę to na monitoringu.

Zaloguj się aby komentować