Hướng dẫn python 3.6 to 3.9 migration - di chuyển python 3.6 sang 3.9
3.11.0 Show
Ngày 17 tháng 11 năm 2022 Biên tập viênŁukasz Langa Bài viết này giải thích các tính năng mới trong Python 3.9, so với 3,8. Python 3.9 được phát hành vào ngày 5 tháng 10 năm 2020. Để biết chi tiết đầy đủ, xem Changelog.changelog. Xem thêm PEP 596 - Lịch phát hành Python 3.9 - Python 3.9 Release Schedule Tóm tắt - Phát hành Điểm nổi bậtCác tính năng cú pháp mới:
Các tính năng tích hợp mới:
Các tính năng mới trong thư viện tiêu chuẩn:
Cải thiện thông dịch viên:
Các mô -đun thư viện mới:
Quy trình phát hành thay đổi:
Bạn nên kiểm tra không dùng nữa trong mã của bạnKhi Python 2.7 vẫn được hỗ trợ, rất nhiều chức năng trong Python 3 được giữ để tương thích ngược với Python 2.7. Với sự kết thúc của hỗ trợ Python 2, các lớp tương thích ngược này đã bị loại bỏ hoặc sẽ sớm bị xóa. Hầu hết trong số họ đã phát ra một cảnh báo Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.37 trong vài năm. Ví dụ: sử dụng Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.38 thay vì Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.39 phát ra Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.37 kể từ Python 3.3, được phát hành vào năm 2012. Kiểm tra ứng dụng của bạn với tùy chọn dòng lệnh int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }1 int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }2 để xem Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.37 và int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }4 hoặc thậm chí với int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }1 int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }6 để coi chúng là lỗi. Bộ lọc cảnh báo có thể được sử dụng để bỏ qua các cảnh báo từ mã của bên thứ ba.Warnings Filter can be used to ignore warnings from third-party code. Python 3.9 là phiên bản cuối cùng cung cấp các lớp tương thích ngược Python 2 đó, để dành nhiều thời gian hơn cho các dự án Python để tổ chức việc loại bỏ hỗ trợ Python 2 và thêm hỗ trợ cho Python 3.9. Bí danh cho các lớp cơ sở trừu tượng trong mô -đun int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }7, như bí danh Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.38 cho Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.39, được giữ cho một bản phát hành cuối cùng để tương thích ngược. Chúng sẽ được gỡ bỏ khỏi Python 3.10.Abstract Base Classes in the int foo_traverse(foo_struct *self, visitproc visit, void *arg) { // Rest of the traverse function #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (Python issue 35810 and 40217) Py_VISIT(Py_TYPE(self)); #endif }7 module, like Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.38 alias to Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.39, are kept for one last release for backward compatibility. They will be removed from Python 3.10. Tổng quát hơn, hãy cố gắng chạy các bài kiểm tra của bạn trong chế độ phát triển Python giúp chuẩn bị mã của bạn để làm cho nó tương thích với phiên bản Python tiếp theo.Python Development Mode which helps to prepare your code to make it compatible with the next Python version. LƯU Ý: Một số phiếu giảm giá có sẵn đã được xóa trong phiên bản Python này. Tham khảo phần bị loại bỏ.Removed section. Các tính năng mới¶Các nhà khai thác và cập nhật từ điển Merge & Cập nhậtCác nhà khai thác hợp nhất ( base->tp_traverse(self, visit, arg)0) và cập nhật ( base->tp_traverse(self, visit, arg)1) đã được thêm vào lớp dict tích hợp. Những người bổ sung cho các phương pháp base->tp_traverse(self, visit, arg)3 và base->tp_traverse(self, visit, arg)4 hiện có để hợp nhất các từ điển. Example: >>> x = {"key1": "value1 from x", "key2": "value2 from x"} >>> y = {"key2": "value2 from y", "key3": "value3 from y"} >>> x | y {'key1': 'value1 from x', 'key2': 'value2 from y', 'key3': 'value3 from y'} >>> y | x {'key2': 'value2 from x', 'key3': 'value3 from y', 'key1': 'value1 from x'} Xem PEP 584 để biết mô tả đầy đủ. (Được đóng góp bởi Brandt Bucher trong BPO-36144.)PEP 584 for a full description. (Contributed by Brandt Bucher in bpo-36144.) Các phương thức chuỗi mới để xóa tiền tố và hậu tốbase->tp_traverse(self, visit, arg)5 và base->tp_traverse(self, visit, arg)6 đã được thêm vào để dễ dàng loại bỏ một tiền tố không cần thiết hoặc hậu tố từ một chuỗi. Các phương pháp tương ứng base->tp_traverse(self, visit, arg)7, base->tp_traverse(self, visit, arg)8 và base->tp_traverse(self, visit, arg)9 cũng đã được thêm vào. Xem PEP 616 để biết mô tả đầy đủ. (Được đóng góp bởi Dennis Sweeney trong BPO-39939.)PEP 616 for a full description. (Contributed by Dennis Sweeney in bpo-39939.) Loại Generics Generics trong Bộ sưu tập tiêu chuẩnTrong các chú thích loại, giờ đây bạn có thể sử dụng các loại thu thập tích hợp như #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else0 và dict dưới dạng các loại chung thay vì nhập các loại được viết hoa tương ứng (ví dụ: #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else2 hoặc #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else3) từ #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else4. Một số loại khác trong thư viện tiêu chuẩn hiện cũng chung chung, ví dụ #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else5. Example: def greet_all(names: list[str]) -> None: for name in names: print("Hello", name) Xem PEP 585 để biết thêm chi tiết. (Được đóng góp bởi Guido van Rossum, Ethan Smith và Batuhan Taşkaya trong BPO-39481.)PEP 585 for more details. (Contributed by Guido van Rossum, Ethan Smith, and Batuhan Taşkaya in bpo-39481.) Trình phân tích cú pháp mớiPython 3.9 sử dụng trình phân tích cú pháp mới, dựa trên PEG thay vì LL (1). Hiệu suất của trình phân tích cú pháp mới gần như tương đương với trình phân tích cú pháp cũ, nhưng hình thức PEG linh hoạt hơn LL (1) khi thiết kế các tính năng ngôn ngữ mới. Chúng tôi sẽ bắt đầu sử dụng tính linh hoạt này trong Python 3.10 trở lên. Mô -đun >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST5 sử dụng trình phân tích cú pháp mới và tạo ra AST giống như trình phân tích cú pháp cũ. Trong Python 3.10, trình phân tích cú pháp cũ sẽ bị xóa và tất cả các chức năng sẽ phụ thuộc vào nó (chủ yếu là mô -đun #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else7, từ lâu đã bị phản đối). Chỉ trong Python 3.9, bạn có thể quay lại trình phân tích cú pháp LL (1) bằng công tắc dòng lệnh ( #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else8) hoặc biến môi trường ( #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else9). Xem PEP 617 để biết thêm chi tiết. (Được đóng góp bởi Guido van Rossum, Pablo Galindo và Lysandros Nikolaou trong BPO-40334.)PEP 617 for more details. (Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou in bpo-40334.) Thay đổi ngôn ngữ khác
Mô -đun mớiZoneinfo¶Mô -đun Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.35 mang lại hỗ trợ cho cơ sở dữ liệu múi giờ IANA cho thư viện tiêu chuẩn. Nó thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)06, triển khai cụ thể def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)07 được hỗ trợ bởi dữ liệu múi giờ của hệ thống. Example: >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST Là một nguồn dữ liệu mùa thu cho các nền tảng không vận chuyển cơ sở dữ liệu IANA, mô-đun ____108 đã được phát hành dưới dạng gói của bên đầu tiên-được phân phối thông qua PYPI và được duy trì bởi nhóm Cpython Core. Xem thêm PEP 615 - Hỗ trợ cho cơ sở dữ liệu múi giờ IANA trong thư viện tiêu chuẩn – Support for the IANA Time Zone Database in the Standard LibraryPEP được viết và thực hiện bởi Paul Ganssle đồ họaMột mô -đun mới, Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.36, đã được thêm vào có chứa lớp def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)10 để cung cấp chức năng để thực hiện phân loại tô màu của các biểu đồ. (Được đóng góp bởi Pablo Galindo, Tim Peters và Larry Hastings trong BPO-17005.) Các mô -đun được cải thiệnthuộc về Ast AstĐã thêm tùy chọn thụt vào def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)11 cho phép nó tạo ra một đầu ra thụt đầu dòng. (Được đóng góp bởi Serhiy Storchaka trong BPO-37995.) Đã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)12 dưới dạng hàm trong mô -đun >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST5 có thể được sử dụng để không phân tách đối tượng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)14 và tạo một chuỗi có mã sẽ tạo ra một đối tượng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)14 tương đương khi được phân tích cú pháp. (Được đóng góp bởi Pablo Galindo và Batuhan Taskaya trong BPO-38870.) Đã thêm Docstrings vào các nút AST chứa chữ ký ASDL được sử dụng để xây dựng nút đó. (Được đóng góp bởi Batuhan Taskaya trong BPO-39638.) không đồng bộDo những lo ngại về bảo mật đáng kể, tham số reuse_address của def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)16 không còn được hỗ trợ. Điều này là do hành vi của tùy chọn ổ cắm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)17 trong UDP. Để biết thêm chi tiết, xem tài liệu cho def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)18. (Được đóng góp bởi Kyle Stanley, Antoine Pitrou và Yury Selivanov trong BPO-37228.) Đã thêm một coroutine def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)19 mới lên lịch tắt máy cho người thực thi mặc định chờ đợi trên def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)20 để kết thúc kết thúc. Ngoài ra, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)21 đã được cập nhật để sử dụng coroutine mới. (Được đóng góp bởi Kyle Stanley trong BPO-34037.)coroutine def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)19 that schedules a shutdown for the default executor that waits on the def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)20 to finish closing. Also, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)21 has been updated to use the new coroutine. (Contributed by Kyle Stanley in bpo-34037.) Đã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)22, một triển khai người theo dõi trẻ em dành riêng cho Linux mà thăm dò các mô tả tệp xử lý. (BPO-38692) Đã thêm một coroutine mới def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)23. Nó chủ yếu được sử dụng để chạy các hàm ràng buộc IO trong một luồng riêng biệt để tránh chặn vòng lặp sự kiện và về cơ bản hoạt động như một phiên bản cấp cao của def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)24 có thể trực tiếp lấy các đối số từ khóa. (Được đóng góp bởi Kyle Stanley và Yury Selivanov trong BPO-32309.)coroutine def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)23. It is mainly used for running IO-bound functions in a separate thread to avoid blocking the event loop, and essentially works as a high-level version of def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)24 that can directly take keyword arguments. (Contributed by Kyle Stanley and Yury Selivanov in bpo-32309.) Khi hủy nhiệm vụ do thời gian chờ, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)25 bây giờ sẽ đợi cho đến khi việc hủy hoàn tất cũng trong trường hợp khi hết thời gian chờ def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)26 Bây giờ tăng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)27 khi gọi các phương thức không tương thích với ổ cắm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)28. (Được đóng góp bởi IDO Michael trong BPO-37404.) Compileall¶Đã thêm khả năng mới để sử dụng các liên kết cứng cho các tệp def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)29 sao chép: tham số HardLink_Dupes và tùy chọn dòng lệnh của HardLink_Dupes và Tùy chọn của HardHardLink-Dupes. (Được đóng góp bởi Lumír ‘Frenzy xông Balhar trong BPO-40495.) Đã thêm các tùy chọn mới để thao tác đường dẫn trong các tệp def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)29: StripDir, predDir, giới hạn_sl_dest tham số và -s, -p, -e Tùy chọn dòng lệnh. Đã thêm khả năng để chỉ định tùy chọn cho mức tối ưu hóa nhiều lần. (Được đóng góp bởi Lumír ‘Frenzy xông Balhar trong BPO-38112.) đồng thời.Đã thêm một tham số Hủy_Futures mới vào def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)31 hủy bỏ tất cả các tương lai đang chờ xử lý chưa bắt đầu chạy, thay vì chờ chúng hoàn thành trước khi tắt người thực thi. (Được đóng góp bởi Kyle Stanley trong BPO-39349.) Đã loại bỏ các luồng daemon khỏi def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)20 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)33. Điều này cải thiện khả năng tương thích với các yếu tố phụ và khả năng dự đoán trong các quy trình tắt máy của họ. (Được đóng góp bởi Kyle Stanley trong BPO-39812.) Công nhân ở def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)33 hiện được sinh ra theo yêu cầu, chỉ khi không có công nhân nhàn rỗi có sẵn để tái sử dụng. Điều này tối ưu hóa chi phí khởi động và giảm thời gian CPU bị mất cho những người lao động nhàn rỗi. (Được đóng góp bởi Kyle Stanley trong BPO-39207.) lời nguyền rủaĐã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)35, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)36, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)37 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)38. (Được đóng góp bởi Anthony Sottile trong BPO-38312.) ngày giờ¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)39 của def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)40 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)39 của các phương thức def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)42 hiện trả về def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)43 thay vì def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)44. (Được đóng góp bởi Dong-hee NA trong BPO-24416.) DisTutils¶Lệnh tải lên hiện đang tạo ra các tiêu hóa băm SHA2-256 và BLAKE2B-256. Nó bỏ qua MD5 trên các nền tảng chặn MD5 Digest. (Được đóng góp bởi Christian Heimes trong BPO-40698.)upload command now creates SHA2-256 and Blake2b-256 hash digests. It skips MD5 on platforms that block MD5 digest. (Contributed by Christian Heimes in bpo-40698.) fcntl¶Đã thêm hằng số def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)45, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)46 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)47. (Được đóng góp bởi Dong-hee NA trong BPO-38602.) ftplib¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)48 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)49 hiện tăng >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "2 nếu thời gian chờ cho hàm tạo của chúng bằng không để ngăn chặn việc tạo ra một ổ cắm không chặn. (Được đóng góp bởi Dong-hee NA trong BPO-39259.) GC¶Khi người thu gom rác tạo ra một bộ sưu tập trong đó một số đối tượng hồi sinh (chúng có thể tiếp cận từ bên ngoài các chu kỳ bị cô lập sau khi các bộ đầu tiên được thực thi), không chặn bộ sưu tập của tất cả các đối tượng vẫn không thể truy cập được. (Được đóng góp bởi Pablo Galindo và Tim Peters trong BPO-38379.) Đã thêm một chức năng mới def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)51 để kiểm tra xem một đối tượng đã được hoàn thành bởi người thu gom rác. (Được đóng góp bởi Pablo Galindo trong BPO-39322.) hăm hashlibMô -đun def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)52 hiện có thể sử dụng băm SHA3 và lắc XOF từ OpenSSL khi có sẵn. (Được đóng góp bởi Christian Heimes trong BPO-37630.) Các mô -đun băm tích hợp hiện có thể bị vô hiệu hóa với def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)53 hoặc được kích hoạt có chọn lọc với ví dụ: def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)54 để buộc sử dụng triển khai dựa trên OpenSSL. (Được đóng góp bởi Christian Heimes trong BPO-40479) http¶Mã trạng thái HTTP def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)55, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)56 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)57 được thêm vào def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)58. (Được đóng góp bởi Dong-hee NA trong BPO-39509 và Ross Rhodes trong BPO-39507.) Nhàn rỗi và idlelib¶Đã thêm tùy chọn để chuyển đổi con trỏ nhấp nháy. (Được đóng góp bởi Zackery Spytz trong BPO-4603.) Khóa thoát ngay bây giờ đóng cửa sổ hoàn thành nhàn rỗi. (Được đóng góp bởi Johnny Najera trong BPO-38944.) Đã thêm từ khóa vào danh sách hoàn thành tên mô -đun. (Được đóng góp bởi Terry J. Reedy trong BPO-37765.) Mới trong 3.9 Phát hành bảo trì Làm cho Idle gọi def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)59 (khi bắt đầu không có ‘-n,). Móc người dùng trước đây đã bị bỏ qua. (Được đóng góp bởi Ken Hilton trong BPO-43008.) Những thay đổi ở trên đã được đưa ra để phát hành bảo trì 3,8. Sắp xếp lại hộp thoại Cài đặt. Chia tab Chung thành các tab Windows và Shell/ED. Di chuyển các nguồn trợ giúp, mở rộng menu trợ giúp, sang tab Tiện ích mở rộng. Tạo không gian cho các tùy chọn mới và rút ngắn hộp thoại. Cái sau làm cho hộp thoại phù hợp hơn với màn hình nhỏ. (Được đóng góp bởi Terry Jan Reedy trong BPO-40468.) Di chuyển cài đặt không gian thụt lề từ tab Phông chữ sang tab Windows mới. (Được đóng góp bởi Mark Roseman và Terry Jan Reedy trong BPO-33962.) Áp dụng cú pháp làm nổi bật vào các tệp def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)60. (Được đóng góp bởi Alex Waygood và Terry Jan Reedy trong BPO-45447.) imaplib¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)61 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)62 hiện có tham số thời gian chờ tùy chọn cho các hàm tạo của chúng. Ngoài ra, phương thức >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "8 hiện có tham số thời gian chờ tùy chọn với thay đổi này. Các phương pháp được ghi đè của def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)62 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)65 đã được áp dụng cho thay đổi này. (Được đóng góp bởi Dong-hee NA trong BPO-38615.) def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)66 được thêm vào. def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)66 Giải phóng các tài nguyên máy chủ của máy chủ được liên kết với hộp thư được chọn và trả máy chủ về trạng thái xác thực. Lệnh này thực hiện các hành động tương tự như def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)68, ngoại trừ không có tin nhắn nào bị xóa vĩnh viễn khỏi hộp thư hiện được chọn. (Được đóng góp bởi Dong-hee NA trong BPO-40375.) nhập khẩuĐể cải thiện tính nhất quán với các báo cáo nhập khẩu, def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)69 hiện tăng >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "1 thay vì >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "2 cho các nỗ lực nhập khẩu tương đối không hợp lệ. (Được đóng góp bởi Ngalim Siregar trong BPO-37444.) Nhập trình tải nhập xuất bản các đối tượng mô -đun bất biến hiện có thể xuất bản các gói bất biến ngoài các mô -đun riêng lẻ. (Được đóng góp bởi Dino Viehland trong BPO-39336.) Đã thêm chức năng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)72 với hỗ trợ cho các thư mục con trong dữ liệu gói, khớp backport trong def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)73 phiên bản 1.5. (Được đóng góp bởi Jason R. Coombs trong BPO-39791.) Được làm mới def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)74 từ def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)75 phiên bản 1.6.1. quan sát¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)76 được thay đổi từ def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)77 thành Dict thông thường. (Được đóng góp bởi Inada Naoki trong BPO-36350 và BPO-39775.) địa chỉ IP¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)78 hiện hỗ trợ địa chỉ phạm vi IPv6 (địa chỉ IPv6 với hậu tố def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)79). Địa chỉ IPv6 có thể được phân tích cú pháp bằng cách sử dụng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)80. Nếu có, ID vùng phạm vi có sẵn thông qua thuộc tính def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)81. (Được đóng góp bởi Oleksandr Pavliuk trong BPO-34788.) Bắt đầu với Python 3.9.5 Mô -đun def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)78 không còn chấp nhận bất kỳ số 0 hàng đầu nào trong chuỗi địa chỉ IPv4. (Được đóng góp bởi Christian Heimes trong BPO-36384). môn Toán¶Đã mở rộng chức năng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)83 để xử lý nhiều đối số. Trước đây, nó chỉ hỗ trợ hai cuộc tranh luận. (Được đóng góp bởi Serhiy Storchaka trong BPO-39648.) Đã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)84: Trả về bội số ít phổ biến nhất của các đối số được chỉ định. (Được đóng góp bởi Mark Dickinson, Ananthakrishnan và Serhiy Storchaka trong BPO-39479 và BPO-39648.) Đã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)85: Trả lại giá trị điểm nổi tiếp theo sau X về phía y. (Được đóng góp bởi Victor Stinner trong BPO-39288.) Đã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)86: Trả về giá trị của bit nổi ít nhất của một chiếc phao. (Được đóng góp bởi Victor Stinner trong BPO-39310.) đa xử lýLớp def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)87 có phương thức def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)88 mới để đóng rõ ràng hàng đợi. (Được đóng góp bởi Victor Stinner trong BPO-30966.) nntplib¶def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)89 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)90 hiện tăng >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "2 nếu thời gian chờ cho hàm tạo của chúng bằng không để ngăn chặn việc tạo ra một ổ cắm không chặn. (Được đóng góp bởi Dong-hee NA trong BPO-39259.) đường xoáyĐã thêm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)92 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)93 cho def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)94. (Được đóng góp bởi Dong-hee NA trong BPO-38493.) Phơi bày các ____99 (BPO-38692) và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)96 (BPO-38713) để quản lý quy trình với các mô tả tệp. Hàm def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)97 hiện cũng có sẵn trên Windows. (Được đóng góp bởi Victor Stinner trong BPO-39413.) Các chức năng def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)98 và def greet_all(names: list[str]) -> None: for name in names: print("Hello", name)97 hiện luôn có sẵn. (Được đóng góp bởi Victor Stinner trong BPO-39395.) Đã thêm hàm >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST00: Chuyển đổi trạng thái chờ thành mã thoát. (Được đóng góp bởi Victor Stinner trong BPO-40094.) Pathlib¶Đã thêm >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST01 hoạt động tương tự như >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST02. (Được đóng góp bởi Girts Folkmanis trong BPO-30618) PDB¶Trên Windows Now >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST03 hỗ trợ >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST04. (Được đóng góp bởi Tim Hopper và Dan Lidral-Porter trong BPO-20523.) cây poplib>>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST05 và >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST06 hiện tăng >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "2 nếu thời gian chờ cho hàm tạo của chúng bằng không để ngăn chặn việc tạo ra một ổ cắm không chặn. (Được đóng góp bởi Dong-hee NA trong BPO-39259.) pprint¶>>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST08 Bây giờ có thể in khá đẹp >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST09. (Được đóng góp bởi Carl Bordum Hansen trong BPO-37376.) pydoc¶Chuỗi tài liệu hiện được hiển thị không chỉ cho lớp, chức năng, phương thức, v.v., mà đối với bất kỳ đối tượng nào có thuộc tính >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST10 riêng. (Được đóng góp bởi Serhiy Storchaka trong BPO-40257.) ngẫu nhiên¶Đã thêm một phương thức >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST11 mới: Tạo các byte ngẫu nhiên. (Được đóng góp bởi Victor Stinner trong BPO-40286.) dấu hiệu¶Lộ >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST12 dành riêng cho Linux để gửi đến tín hiệu đến một quy trình bằng cách sử dụng bộ mô tả tệp thay vì PID. (BPO-38712) smtplib¶>>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST13 và >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST14 hiện tăng >>> from typing import Literal >>> Literal[{0}] >>> Literal[{0}] == Literal[{False}] Traceback (most recent call last): File "2 nếu thời gian chờ cho hàm tạo của chúng bằng không để ngăn chặn việc tạo ra một ổ cắm không chặn. (Được đóng góp bởi Dong-hee NA trong BPO-39259.) >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST16 Constructor hiện có tham số thời gian chờ tùy chọn. (Được đóng góp bởi Dong-hee NA trong BPO-39329.) ổ cắm¶Mô -đun >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST17 hiện xuất xuất hằng số >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST18 trên Linux 4.1 và lớn hơn. (Được đóng góp bởi Stefan Tatschner và Zackery Spytz trong BPO-25780.) Mô -đun ổ cắm hiện hỗ trợ giao thức >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST19 trên các nền tảng hỗ trợ nó. (Được đóng góp bởi Karl ding trong BPO-40291.) Mô -đun ổ cắm hiện có các hàm >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST20 và >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST21. (Được đóng góp bởi Joannah Nanjekye, Shinya Okano và Victor Stinner trong BPO-28724.) thời gian¶Trên AIX, >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST22 hiện được triển khai với >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST23 có độ phân giải nano giây, thay vì >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST24 có độ phân giải 10 mili giây. (Được đóng góp bởi Batuhan Taskaya trong BPO-40192) sys¶Đã thêm một thuộc tính >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST25 mới: Tên của thư mục thư viện cụ thể nền tảng. Nó được sử dụng để xây dựng đường dẫn của thư viện tiêu chuẩn và các đường dẫn của các mô -đun mở rộng được cài đặt. Nó bằng >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST26 trên hầu hết các nền tảng. Trên Fedora và Suse, nó bằng >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST27 trên các nền tảng 64 bit. . Trước đây, >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST28 đã bị chặn khi không tương tác. Bây giờ >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST29 mặc định luôn luôn được đệm. (Được đóng góp bởi Jendrik Seipp trong BPO-13601.) tracemalloc¶Đã thêm >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST30 để đặt kích thước cực đại của các khối bộ nhớ theo dõi thành kích thước hiện tại, để đo cực đại của các đoạn mã cụ thể. (Được đóng góp bởi Huon Wilson trong BPO-40630.) đánh máy¶PEP 593 đã giới thiệu một loại >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST31 type to decorate existing types with context-specific metadata and new >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST32 parameter to >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST33 to access the metadata at runtime. (Contributed by Till Varoquaux and Konstantin Kashin.) unicodedata¶Cơ sở dữ liệu Unicode đã được cập nhật lên phiên bản 13.0.0. (BPO-39926). venv¶Các tập lệnh kích hoạt được cung cấp bởi >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST34 Bây giờ tất cả chỉ định tùy chỉnh nhanh chóng của chúng một cách nhất quán bằng cách luôn sử dụng giá trị được chỉ định bởi >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST35. Trước đây, một số tập lệnh được sử dụng vô điều kiện >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST35, một số khác chỉ khi nó được đặt (đó là trường hợp mặc định) và thay vào đó, một kịch bản được sử dụng. (Được đóng góp bởi Brett Cannon trong BPO-37663.) xml¶Các ký tự không gian trắng trong các thuộc tính hiện được bảo tồn khi tuần tự hóa >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST38 sang tệp XML. Eolns không còn được chuẩn hóa thành từ N N. Đây là kết quả của cuộc thảo luận về cách diễn giải Phần 2.11 của Spec XML. (Được đóng góp bởi Mefistotelis trong BPO-39011.) Tối ưu hóa Or
Tại đây, một bản tóm tắt các cải tiến hiệu suất từ Python 3,4 đến Python 3.9: Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.3 Những kết quả này được tạo ra từ tập lệnh điểm chuẩn truy cập thay đổi tại: >>> from zoneinfo import ZoneInfo >>> from datetime import datetime, timedelta >>> # Daylight saving time >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) >>> print(dt) 2020-10-31 12:00:00-07:00 >>> dt.tzname() 'PDT' >>> # Standard time >>> dt += timedelta(days=7) >>> print(dt) 2020-11-07 12:00:00-08:00 >>> print(dt.tzname()) PST54. Kịch bản điểm chuẩn hiển thị thời gian tính bằng nano giây. Các điểm chuẩn được đo trên bộ xử lý Intel® Core ™ I7-4960HQ chạy các bản dựng MacOS 64 bit được tìm thấy tại Python.org. Không mất giá
Loại bỏ¶
Chuyển sang Python 3.9¶Phần này liệt kê các thay đổi được mô tả trước đây và các lỗi khác có thể yêu cầu thay đổi mã của bạn. Những thay đổi trong API Python
Những thay đổi trong C API¶
CPYTHON BYTECODE thay đổi Or
Xây dựng thay đổi Jor
C API thay đổi BurCác tính năng mới¶
Chuyển sang Python 3.9¶
Loại bỏ¶
Những thay đổi đáng chú ý trong Python 3.9.1¶đánh máy¶Hành vi của #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else01 đã được thay đổi thành phù hợp với PEP 586 và để phù hợp với hành vi của các trình kiểm tra loại tĩnh được chỉ định trong PEP.PEP 586 and to match the behavior of static type checkers specified in the PEP.
(Được đóng góp bởi Yurii Karabas trong BPO-42345.) MacOS 11.0 (Big Sur) và Apple Silicon Mac hỗ trợTính đến 3.9.1, Python hiện hoàn toàn hỗ trợ việc xây dựng và chạy trên MacOS 11.0 (Big Sur) và trên Apple Silicon Macs (dựa trên kiến trúc #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else11). Một biến thể xây dựng phổ quát mới, #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else12, hiện có sẵn để hỗ trợ tự nhiên cả #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else11 và #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else14 trong một bộ thực thi. Các nhị phân hiện cũng có thể được xây dựng trên các phiên bản macOS hiện tại sẽ được triển khai trên một loạt các phiên bản MacOS cũ hơn (được thử nghiệm đến 10.9) trong khi tạo ra một số chức năng HĐH mới hơn và các tùy chọn có điều kiện dựa trên phiên bản hệ điều hành được sử dụng trong thời gian chạy ( ). (Được đóng góp bởi Ronald Oussoren và Lawrence DiênAna trong BPO-41100.) Những thay đổi đáng chú ý trong Python 3.9.2¶bộ sưu tập.abc¶#if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else15 Generic hiện đang làm phẳng các tham số loại, tương tự như những gì #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else16 hiện đang làm. Điều này có nghĩa là #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else17 sẽ có #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else18 của #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else19; Trước đây đây là #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else20. Để cho phép thay đổi này, #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else21 hiện có thể được phân nhóm và một lớp con sẽ được trả lại khi đăng ký loại #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else15. Mã truy cập các đối số thông qua #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else23 hoặc #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else18 cần tính đến thay đổi này. A Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.37 có thể được phát ra cho các hình thức tham số hóa không hợp lệ #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else15 có thể đã được thông qua âm thầm trong Python 3.9.1. Python version 3.4 3.5 3.6 3.7 3.8 3.9 -------------- --- --- --- --- --- --- Variable and attribute read access: read_local 7.1 7.1 5.4 5.1 3.9 3.9 read_nonlocal 7.1 8.1 5.8 5.4 4.4 4.5 read_global 15.5 19.0 14.3 13.6 7.6 7.8 read_builtin 21.1 21.6 18.5 19.0 7.5 7.8 read_classvar_from_class 25.6 26.5 20.7 19.5 18.4 17.9 read_classvar_from_instance 22.8 23.5 18.8 17.1 16.4 16.9 read_instancevar 32.4 33.1 28.0 26.3 25.4 25.3 read_instancevar_slots 27.8 31.3 20.8 20.8 20.2 20.5 read_namedtuple 73.8 57.5 45.0 46.8 18.4 18.7 read_boundmethod 37.6 37.9 29.6 26.9 27.7 41.1 Variable and attribute write access: write_local 8.7 9.3 5.5 5.3 4.3 4.3 write_nonlocal 10.5 11.1 5.6 5.5 4.7 4.8 write_global 19.7 21.2 18.0 18.0 15.8 16.7 write_classvar 92.9 96.0 104.6 102.1 39.2 39.8 write_instancevar 44.6 45.8 40.0 38.9 35.5 37.4 write_instancevar_slots 35.6 36.1 27.3 26.6 25.7 25.8 Data structure read access: read_list 24.2 24.5 20.8 20.8 19.0 19.5 read_deque 24.7 25.5 20.2 20.6 19.8 20.2 read_dict 24.3 25.7 22.3 23.0 21.0 22.4 read_strdict 22.6 24.3 19.5 21.2 18.9 21.5 Data structure write access: write_list 27.1 28.5 22.5 21.6 20.0 20.0 write_deque 28.7 30.1 22.7 21.8 23.5 21.7 write_dict 31.4 33.3 29.3 29.2 24.7 25.4 write_strdict 28.4 29.9 27.5 25.2 23.1 24.5 Stack (or queue) operations: list_append_pop 93.4 112.7 75.4 74.2 50.8 50.6 deque_append_pop 43.5 57.0 49.4 49.2 42.5 44.2 deque_append_popleft 43.7 57.3 49.7 49.7 42.8 46.4 Timing loop: loop_overhead 0.5 0.6 0.4 0.3 0.3 0.37 này sẽ trở thành os.pidfd_open() 8 trong Python 3.10. (Được đóng góp bởi Ken Jin trong BPO-42195.)Urllib.parse¶Các phiên bản Python trước đó cho phép sử dụng cả #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else29 và #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else30 làm dấu phân cách tham số truy vấn trong #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else31 và #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else32. Do các mối quan tâm về bảo mật và để phù hợp với các đề xuất W3C mới hơn, điều này đã được thay đổi để chỉ cho phép một phím phân tách duy nhất, với #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else30 làm mặc định. Thay đổi này cũng ảnh hưởng đến #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else34 và #if PY_VERSION_HEX >= 0x03090000 // This was not needed before Python 3.9 (bpo-35810 and bpo-40217) if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { Py_VISIT(Py_TYPE(self)); } #else35 khi họ sử dụng các chức năng bị ảnh hưởng trong nội bộ. Để biết thêm chi tiết, xin vui lòng xem tài liệu tương ứng của họ. (Được đóng góp bởi Adam Goldschmidt, Senthil Kumaran và Ken Jin trong BPO-42967.) Python 3.9 có tương thích ngược không?Python 3.9 là phiên bản cuối cùng cung cấp các lớp tương thích ngược Python 2 đó, để dành nhiều thời gian hơn cho các dự án Python để tổ chức việc loại bỏ hỗ trợ Python 2 và thêm hỗ trợ cho Python 3.9., to give more time to Python projects maintainers to organize the removal of the Python 2 support and add support for Python 3.9.
Python 3.6 có bị phản đối không?Sau khi phát hành Python 3.9, Vercel đang phản đối sự hỗ trợ cho Python 3.6 đã kết thúc cuộc đời năm ngoái.Vào ngày 18 tháng 7 năm 2022, các triển khai mới nhắm mục tiêu Python 3.6 sẽ thất bại với một thông báo lỗi.Triển khai hiện tại sẽ không bị ảnh hưởng.
Python 3.9 có tốt hơn không?Mỗi bản sửa đổi của Python đều được cải thiện hiệu suất so với phiên bản trước.Python 3.9 cuộn trong hai cải tiến lớn giúp tăng hiệu suất mà không yêu cầu bất kỳ thay đổi nào đối với mã hiện có.Cải tiến đầu tiên liên quan đến việc sử dụng nhiều giao thức VectorCall được giới thiệu trong Python 3.8.Python 3.9 rolls in two big improvements that boost performance without requiring any changes to existing code. The first improvement involves more use of the vectorcall protocol introduced in Python 3.8. |