{"id":2439110,"date":"2025-02-28T03:20:42","date_gmt":"2025-02-28T03:20:42","guid":{"rendered":"https:\/\/www.wacoca.com\/news\/2439110\/"},"modified":"2025-02-28T03:20:42","modified_gmt":"2025-02-28T03:20:42","slug":"python-3-13%e3%81%a7%e6%9b%b4%e6%96%b0%e3%81%95%e3%82%8c%e3%81%9f%e6%a9%9f%e8%83%bd%e3%81%ae%e7%b4%b9%e4%bb%8b-gihyo-jp","status":"publish","type":"post","link":"https:\/\/www.wacoca.com\/news\/2439110\/","title":{"rendered":"Python 3.13\u3067\u66f4\u65b0\u3055\u308c\u305f\u6a5f\u80fd\u306e\u7d39\u4ecb | gihyo.jp"},"content":{"rendered":"<p id=\"gh2YJkGchK\">\u9580\u8107\uff08@satoru_kadowaki\uff09\u3067\u3059\u30022025\u5e742\u6708\u306e\u300cPython Monthly Topics\u300d\u306f\u3001Python 3.13\u3067\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3055\u308c\u305f\u6a5f\u80fd\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p id=\"gh4EPg2SZe\">\u3054\u5b58\u77e5\u306e\u3088\u3046\u306b\u3001Python 3.13\u306f2024\u5e7410\u6708\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3001\u591a\u304f\u306e\u6539\u5584\u3068\u65b0\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p id=\"gh9JqEi_aB\">\u672c\u8a18\u4e8b\u3067\u306f\u3001\u5177\u4f53\u7684\u306b\u3069\u306e\u3088\u3046\u306a\u70b9\u304c\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u3001\u4e3b\u306a\u6a5f\u80fd\u3092\u30d4\u30c3\u30af\u30a2\u30c3\u30d7\u3057\u3066\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u65b0\u3057\u3044\u5bfe\u8a71\u578b\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3068\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8<\/p>\n<p id=\"gh3CwKhs7q\">\u4eca\u56de\u306e\u30ea\u30ea\u30fc\u30b9\u306b\u304a\u3051\u308b\u6700\u3082\u5927\u304d\u306a\u5909\u66f4\u70b9\u306e1\u3064\u3068\u3057\u3066\u3001\u65b0\u3057\u3044\u5bfe\u8a71\u578b\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306fPython 3.10\u4ee5\u964d\u7d99\u7d9a\u7684\u306b\u6539\u5584\u3055\u308c\u3066\u304a\u308a\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u4e0a\u304c\u308b\u3054\u3068\u306b\u30a8\u30e9\u30fc\u5185\u5bb9\u304c\u7406\u89e3\u3057\u3084\u3059\u304f\u306a\u308a\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4fee\u6b63\u304c\u52b9\u7387\u7684\u306b\u884c\u3048\u308b\u3088\u3046\u9032\u5316\u3057\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p id=\"ghekcz_iGK\">\u6700\u521d\u306b\u3053\u306e2\u3064\u306b\u3064\u3044\u3066\u7c21\u5358\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u5bfe\u8a71\u578b\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u306e\u6539\u5584<\/p>\n<p id=\"ghPHNVBJZD\">\u65b0\u3057\u3044\u5bfe\u8a71\u578b\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u306e\u4e3b\u306a\u7279\u5fb4\u306b\u306f\u4ee5\u4e0b\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u3084\u30c8\u30ec\u30fc\u30b9\u30d0\u30c3\u30af\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30ab\u30e9\u30fc\u8868\u793a\u3055\u308c\u3001\u8996\u8a8d\u6027\u304c\u5411\u4e0a\u3057\u305f<br \/>\n\u95a2\u6570\u3084\u30af\u30e9\u30b9\u306a\u3069\u306e\u8907\u6570\u884c\u306b\u308f\u305f\u308b\u30b3\u30fc\u30c9\u306e\u7de8\u96c6\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f<br \/>\nexit\u3084quit\u306a\u3069\u306e\u30b3\u30de\u30f3\u30c9\u304c\u62ec\u5f27\u306a\u3057\u3067\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f<br \/>\n\u30d5\u30a1\u30f3\u30af\u30b7\u30e7\u30f3\u30ad\u30fc\u3078\u6a5f\u80fd\u304c\u5272\u308a\u5f53\u3066\u3089\u308c\u305f<\/p>\n<p>F1\u30ad\u30fc: \u30d8\u30eb\u30d7\u306e\u8868\u793a<br \/>\nF2\u30ad\u30fc: \u30b3\u30de\u30f3\u30c9\u306e\u5c65\u6b74\u3092\u30d6\u30e9\u30a6\u30ba<br \/>\nF3\u30ad\u30fc: \u30da\u30fc\u30b9\u30c8\u30e2\u30fc\u30c9\u3067\u5927\u304d\u306a\u30b3\u30fc\u30c9\u30d6\u30ed\u30c3\u30af\u3092\u8cbc\u308a\u4ed8\u3051<\/p>\n<p id=\"gh8rmj6dq6\">\u53c2\u8003\u307e\u3067\u306b\u3001\u5b9f\u969b\u306b\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3067\u5b9f\u884c\u3057\u305f\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<p><img src=\"https:\/\/www.wacoca.com\/news\/wp-content\/uploads\/2025\/02\/001.gif\" alt=\"\u65b0\u3057\u3044\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3092\u5b9f\u884c\u3057\u305f\u69d8\u5b50\" decoding=\"async\" loading=\"lazy\" width=\"1000\" height=\"340\"\/><\/p>\n<p>\u3055\u3089\u306b\u6539\u5584\u3055\u308c\u305f\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8<\/p>\n<p id=\"gh6n1FeGSd\">\u5148\u8ff0\u306e\u3068\u304a\u308a\u3001\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u306e\u66f4\u65b0\u306b\u4f34\u3044\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3082\u30ab\u30e9\u30fc\u5316\u3055\u308c\u307e\u3057\u305f\u3002\u30a8\u30e9\u30fc\u306e\u7a2e\u985e\u3084\u95a2\u4fc2\u3059\u308b\u30b3\u30fc\u30c9\u90e8\u5206\u304c\u8272\u5206\u3051\u3055\u308c\u308b\u3053\u3068\u3067\u3001\u8996\u899a\u7684\u306b\u91cd\u8981\u306a\u60c5\u5831\u3092\u7c21\u5358\u306b\u78ba\u8a8d\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p id=\"gh6GhtjJ8d\">\u5177\u4f53\u7684\u306b\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002Python 3.12\u307e\u3067\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u306fIndexError: list index out of range\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p><img src=\"https:\/\/www.wacoca.com\/news\/wp-content\/uploads\/2025\/02\/1740712840_477_002.png\" alt=\"Python3.12\u3067\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u8868\u793a\" decoding=\"async\" loading=\"lazy\" width=\"800\" height=\"185\"\/><\/p>\n<p id=\"gh5FvtD0fc\">Python 3.13\u3067\u3082\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u81ea\u4f53\u306f\u540c\u3058\u3067\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5177\u4f53\u7684\u306a\u30a8\u30e9\u30fc\u90e8\u5206\u304c\u30ab\u30e9\u30fc\u8868\u793a\u3067\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u6a19\u6e96\u5165\u529b\u306b\u3064\u3044\u3066\u306f\u306e\u3088\u3046\u306b\u5909\u66f4\u3055\u308c\u3001\u672b\u5c3e\u306e\u6570\u5b57\u306f\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3067\u5b9f\u884c\u3055\u308c\u305f\u5165\u529b\u9806\u306b\u756a\u53f7\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img src=\"https:\/\/www.wacoca.com\/news\/wp-content\/uploads\/2025\/02\/003.png\" alt=\"Python3.12\u3067\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u8868\u793a\" decoding=\"async\" loading=\"lazy\" width=\"800\" height=\"222\"\/><\/p>\n<p>\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u2060\u30fb\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u885d\u7a81\u304c\u3088\u308a\u660e\u78ba\u306b<\/p>\n<p id=\"gheaw5TBPD\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u3001\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u540d\u524d\u3068\u306e\u885d\u7a81\u306b\u3064\u3044\u3066\u3082\u6539\u5584\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u3067\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30ebsecrets.py\u304c\u3001\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3042\u308bsecrets\u3068\u885d\u7a81\u3057\u3066\u3044\u308b\u72b6\u614b\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>$ tree<br \/>\n.<br \/>\n\u251c\u2500\u2500 example_err.py<br \/>\n\u2514\u2500\u2500 secrets.py<\/p>\n<p id=\"gh1J6NGaoy\">\u30b5\u30f3\u30d7\u30eb\u306e\u305f\u3081\u3001secrets.py\u306f\u7a7a\u306b\u3057\u3066\u3001\u4ee5\u4e0b\u306eexample_err.py\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30b9\u30c8 example_err.py\uff1a\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u540c\u540d\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8<br \/>\nimport secrets<\/p>\n<p>print(secrets.token_bytes())<\/p>\n<p id=\"gh2Xq8vaNb\">\u4e0a\u8a18\u3092Python 3.12\u3067\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bAttributeError: module &#8216;secrets&#8217; has no attribute &#8216;token_bytes&#8217;\u3060\u3051\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>$ python3.12 example_err.py<br \/>\nTraceback (most recent call last):<br \/>\n  File &#8220;\/home\/ubuntu\/example_err.py&#8221;, line 3, in<br \/>\n    print(secrets.token_bytes())<br \/>\n          ^^^^^^^^^^^^^^^^^^^<br \/>\nAttributeError: module &#8216;secrets&#8217; has no attribute &#8216;token_bytes&#8217;<\/p>\n<p id=\"gh7iaq5CSJ\">Python 3.13\u3067\u306f\u540c\u3058\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u4ed6\u306b\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u3068\u885d\u7a81\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u5177\u4f53\u7684\u306b\u793a\u3055\u308c\u307e\u3059\uff08\u30b5\u30f3\u30d7\u30eb\u306e\u51fa\u529b\u7d50\u679c\u306f\u3001\u898b\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b\u6539\u884c\u3092\u3044\u308c\u3066\u3044\u307e\u3059\u2060\uff09\u2060\u3002\u51fa\u529b\u7d50\u679c\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001consider renaming&#8230;\/secrets.py\u90e8\u5206\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5909\u66f4\u3092\u4fc3\u3059\u3068\u3068\u3082\u306b\u3001the same name as the standard library module named &#8216;secrets&#8217;\u3068\u3044\u3046\u90e8\u5206\u3067\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306esecrets\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u540c\u3058\u540d\u524d\u3067\u3042\u308b\u3053\u3068\u304c\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p id=\"gh24Pj8hHu\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u5177\u4f53\u7684\u306b\u554f\u984c\u3092\u6307\u6458\u3057\u3066\u304f\u308c\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u8fc5\u901f\u306b\u554f\u984c\u3092\u628a\u63e1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u306f\u3068\u3066\u3082\u3042\u308a\u304c\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>$ python3.13 example_err.py<br \/>\nTraceback (most recent call last):<br \/>\n  File &#8220;\/home\/ubuntu\/example_err.py&#8221;, line 3, in<br \/>\n    print(secrets.token_bytes())<br \/>\n          ^^^^^^^^^^^^^^^^^^^<br \/>\nAttributeError: module &#8216;secrets&#8217; has no attribute &#8216;token_bytes&#8217;<br \/>\n(consider renaming &#8216;\/home\/ubuntu\/secrets.py&#8217; since it has<br \/>\nthe same name as the standard library module named &#8216;secrets&#8217;<br \/>\nand prevents importing that standard library module)<\/p>\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u306b\u3080\u3051\u305f\u53d6\u308a\u7d44\u307f<\/p>\n<p id=\"gh3KtdEIBU\">\u7d9a\u3044\u3066\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u95a2\u3059\u308b\u5185\u5bb9\u306b\u3064\u3044\u3066\u898b\u3066\u3044\u304d\u307e\u3059\u3002Python 3.13\u3067\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u3092\u76ee\u7684\u3068\u3057\u3066\u3001\u5b9f\u9a13\u7684\u306b\u4ee5\u4e0b\u304c\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u9a13\u7684\u306aJIT\uff08Just-In-Time\uff09\u30b3\u30f3\u30d1\u30a4\u30eb\u306e\u5c0e\u5165<\/p>\n<p id=\"ghv_m8TJx6\">Python 3.13\u3067\u306f\u3001PEP 744\u3067\u5b9f\u9a13\u7684\u306aJIT\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002JIT\u30b3\u30f3\u30d1\u30a4\u30e9\u306f\u3001\u95a2\u6570\u306a\u3069\u306e\u983b\u7e41\u306b\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30fc\u30c9\u3092\u691c\u51fa\u3057\u3001\u6700\u9069\u5316\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u5b9f\u884c\u901f\u5ea6\u306e\u5411\u4e0a\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u304c\u3001\u73fe\u6642\u70b9\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u7121\u52b9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u5229\u7528\u3059\u308b\u306b\u306f&#8211;enable-experimental-jit\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066Python\u3092\u30d3\u30eb\u30c9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p id=\"ghFBJyOlvK\">\u4ee5\u4e0b\u306b\u5177\u4f53\u7684\u306a\u30d3\u30eb\u30c9\u624b\u9806\u3092\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u3001ubuntu\uff08Linux\uff09\u3092\u4f7f\u7528\u3057\u3066\u30d3\u30eb\u30c9\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p># \u95a2\u9023\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u66f4\u65b0\/\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n$ sudo apt update<br \/>\n$ sudo apt install build-essential zlib1g-dev \\<br \/>\n&gt; libncurses5-dev libgdbm-dev libnss3-dev libssl-dev \\<br \/>\n&gt; libreadline-dev libffi-dev curl clang<br \/>\n# Python 3.13.2\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<br \/>\n$ curl -O hhttps:\/\/www.python.org\/ftp\/python\/3.13.2\/Python-3.13.2.tgz<br \/>\n$ tar zxvf Python-3.13.2.tgz<br \/>\n$ cd Python-3.13.2<br \/>\n# Python\u3092\u30d3\u30eb\u30c9 JIT\u3092\u6709\u52b9\u306b\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a<br \/>\n$ .\/configure &#8211;enable-experimental-jit &#8211;enable-optimizations<br \/>\n$ make<\/p>\n<p id=\"ghdrdT1R1x\">\u5b9f\u969b\u306b\u30b7\u30b9\u30c6\u30e0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u8ffd\u52a0\u3067sudo make install\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4eca\u56de\u306f\u78ba\u8a8d\u3092\u884c\u3046\u3060\u3051\u3067\u3059\u306e\u3067\u3001Python-3.13.2\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u30d3\u30eb\u30c9\u3055\u308c\u305fPython\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p id=\"gh3RHQ_2BR\">\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002JIT\u306b\u3088\u308b\u52b9\u679c\u3092\u5f97\u308b\u305f\u3081\u306b\u3001\u5358\u7d14\u306a\u6570\u5024\u8a08\u7b97\u90e8\u5206\u3092\u95a2\u6570\u5316\u3057\u3066\u6642\u9593\u8a08\u6e2c\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30b9\u30c8 example_jit.py\uff1aJIT\u3092\u8a66\u3059\u30b7\u30f3\u30d7\u30eb\u306a\u8a08\u7b97\u30b9\u30af\u30ea\u30d7\u30c8<br \/>\nimport time<\/p>\n<p>def simple_calc(n: int) -&gt; int:<br \/>\n    res = 0<br \/>\n    for i in range(1, n):<br \/>\n        res += (i * 3.14159) ** 2<br \/>\n    return res<\/p>\n<p>start = time.time()<\/p>\n<p>n = 10**8<br \/>\nresult = simple_calc(n)<\/p>\n<p>end = time.time()<br \/>\nduration = end &#8211; start<br \/>\nprint(f&#8221;\u5b9f\u884c\u6642\u9593: {duration:.3f} \u79d2&#8221;)<\/p>\n<p id=\"gh7_n3SWz3\">\u307e\u305a\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306ePython 3.12\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>$ python3.12 example_jit.py<br \/>\n\u5b9f\u884c\u6642\u9593: 5.203 \u79d2<\/p>\n<p id=\"gh1auyXWZR\">\u5b9f\u884c\u7d50\u679c\u306f5\u79d2\u7a0b\u5ea6\u3067\u3057\u305f\u3002\u7d9a\u3044\u3066\u3001\u624b\u52d5\u30d3\u30eb\u30c9\u3057\u305fPython 3.13\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002\u5b9f\u884c\u6642\u306bJIT\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001\u74b0\u5883\u5909\u6570\u306bPYTHON_JIT=1\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p># (\u5b9f\u884c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea) .\/Python-3.13.2\/<br \/>\n$ PYTHON_JIT=1 .\/python ..\/example_jit.py<br \/>\n\u5b9f\u884c\u6642\u9593: 3.716 \u79d2<\/p>\n<p id=\"gh4gg8TLmd\">\u5b9f\u884c\u7d50\u679c\u306f4\u79d2\u5f31\u3068\u306a\u308a\u307e\u3057\u305f\u3002\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f30\uff05\u4ee5\u4e0a\u306e\u901f\u5ea6\u6539\u5584\u304c\u5f97\u3089\u308c\u307e\u3057\u305f\u304c\u3001JIT\u306b\u3088\u308b\u6700\u9069\u5316\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u52b9\u679c\u3092\u5f97\u3089\u308c\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30d7\u304c\u591a\u7528\u3055\u308c\u308b\u30b3\u30fc\u30c9\uff1a\u30eb\u30fc\u30d7\u51e6\u7406\u3067\u306f\u3001\u540c\u3058\u51e6\u7406\u304c\u4f55\u5ea6\u3082\u5b9f\u884c\u3055\u308c\u308b\u305f\u3081\u3001\u9ad8\u901f\u5316\u304c\u671f\u5f85\u3067\u304d\u307e\u3059<br \/>\n\u6570\u5024\u8a08\u7b97\u3084CPU\u30d0\u30a6\u30f3\u30c9\u306a\u51e6\u7406\uff1a\u4e3b\u306bCPU\u3092\u4f7f\u3046\u51e6\u7406\u3067\u306f\u3001JIT\u306e\u6700\u9069\u5316\u304c\u76f4\u63a5\u7684\u306b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u306b\u3064\u306a\u304c\u308a\u307e\u3059<br \/>\n\u983b\u7e41\u306a\u95a2\u6570\u547c\u3073\u51fa\u3057\u304c\u884c\u308f\u308c\u308b\u51e6\u7406\uff1a\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3055\u308c\u308b\u95a2\u6570\u306f\u3001\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u306a\u3069\u3092\u524a\u6e1b\u3059\u308b\u52b9\u679c\u304c\u671f\u5f85\u3067\u304d\u307e\u3059<\/p>\n<p id=\"gh2hqLQS3C\">\u524d\u8ff0\u306e\u3068\u304a\u308a\u3001JIT\u306e\u5c0e\u5165\u306fPython 3.13\u3067\u306f\u5b9f\u9a13\u7684\u306a\u3082\u306e\u3067\u3059\u304c\u3001\u4eca\u5f8c\u306e\u30ea\u30ea\u30fc\u30b9\u306b\u5411\u3051\u3066\u7d99\u7d9a\u3057\u3066\u66f4\u65b0\u3055\u308c\u308b\u3053\u3068\u304c\u4e88\u60f3\u3055\u308c\u3001\u3055\u3089\u306b\u6539\u5584\u3055\u308c\u308b\u898b\u8fbc\u307f\u3067\u3059\u3002\u306a\u304a\u3001\u4ee5\u4e0b\u306ePyCon US 2024\u306e\u30ec\u30dd\u30fc\u30c8\u306b\u306f\u3001JIT\u306b\u95a2\u3059\u308b\u958b\u767a\u306e\u80cc\u666f\u306b\u3064\u3044\u3066\u306e\u8a18\u8f09\u304c\u3042\u308a\u307e\u3059\u3002\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u305c\u3072\u8aad\u3093\u3067\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>GIL\uff08Global Interpreter Lock\uff09\u306e\u7121\u52b9\u5316<\/p>\n<p id=\"ghdG0ZX20T\">JIT\u3068\u540c\u69d8\u306b\u3001Python 3.13\u3067\u306f\uff08PEP 703\uff09\u3067\u5b9f\u9a13\u7684\u306b\u30d5\u30ea\u30fc\u30b9\u30ec\u30c3\u30c9\u30e2\u30fc\u30c9\u304c\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002\u30d5\u30ea\u30fc\u30b9\u30ec\u30c3\u30c9\u30e2\u30fc\u30c9\u3067\u306fGIL\u3092\u7121\u52b9\u5316\u3057\u3001\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u3067\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u3092\u76ee\u7684\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p id=\"ghahAdfJgU\">GIL\u3068\u306f\u3001Python\u306e\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u304c\u4e00\u5ea6\u306b1\u3064\u306e\u30b9\u30ec\u30c3\u30c9\u306e\u307f\u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u30ed\u30c3\u30af\u306e\u3053\u3068\u3067\u3059\u3002Python\u306b\u304a\u3051\u308b\u5927\u304d\u306a\u5236\u7d04\u3067\u3001GIL\u306e\u5b58\u5728\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u3068\u306a\u308b\u3053\u3068\u304c\u3057\u3070\u3057\u3070\u3042\u308a\u307e\u3059\u3002<\/p>\n<p id=\"gh3fqsbDiM\">Python 3.13\u3067\u306f\u3001&#8211;disable-gil\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30d3\u30eb\u30c9\u3059\u308b\u3053\u3068\u3067\u5b9f\u9a13\u7684\u306bGIL\u306e\u6392\u4ed6\u5236\u5fa1\u3092\u7121\u52b9\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u4ee5\u4e0b\u306e\u30ea\u30f3\u30af\u306b\u3042\u308b\u624b\u9806\u3092\u884c\u3048\u3070\u3001\u3059\u3067\u306b\u30d3\u30eb\u30c9\u6e08\u307f\u306e\u30d0\u30a4\u30ca\u30ea\u3092\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p id=\"ghbF1U_r_N\">GIL\u306e\u7121\u52b9\u5316\u306b\u3064\u3044\u3066\u3082\u3001\u5b89\u5b9a\u6027\u3084\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u901a\u5e38\u306e\u5229\u7528\u306b\u304a\u3044\u3066\u5fc5\u305a\u3057\u3082\u6539\u5584\u3055\u308c\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u307e\u3060\u5b9f\u9a13\u7684\u306a\u6bb5\u968e\u3067\u3059\u3002\u5c06\u6765\u7684\u306a\u6539\u5584\u306b\u671f\u5f85\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n<p>\u578b\u30d2\u30f3\u30c8<\/p>\n<p id=\"gh8kXvnEvX\">Python 3.13\u3067\u306f\u3001\u578b\u30d2\u30f3\u30c8\u306b\u3064\u3044\u3066\u3082\u67d4\u8edf\u6027\u3084\u5b89\u5168\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u304c\u5c0e\u5165\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u6539\u5584\u5185\u5bb9\u3092\u7c21\u5358\u306b\u307e\u3068\u3081\u308b\u3068\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>PEP<br \/>\n\u5909\u66f4\u5185\u5bb9<\/p>\n<p>PEP 696<br \/>\nTypeVar\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u8a2d\u5b9a\u304c\u53ef\u80fd\u306b<\/p>\n<p>PEP 702<br \/>\nwarnings.deprecated()\u30c7\u30b3\u30ec\u30fc\u30bf\u3067\u95a2\u6570\u3084\u30af\u30e9\u30b9\u306e\u975e\u63a8\u5968\u3092\u8b66\u544a\u3057\u3001\u578b\u30c1\u30a7\u30c3\u30ab\u30fc\u3067\u3082\u78ba\u8a8d\u3067\u304d\u308b<\/p>\n<p>PEP 705<br \/>\ntyping.ReadOnly\u3067TypedDict\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8aad\u307f\u53d6\u308a\u5c02\u7528\uff08\u5909\u66f4\u4e0d\u53ef\uff09\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3001\u578b\u30c1\u30a7\u30c3\u30ab\u30fc\u3067\u78ba\u8a8d\u3067\u304d\u308b<\/p>\n<p>PEP 742<br \/>\ntyping.TypeIs\u3092TypeGuard\u306e\u4ee3\u66ff\u3068\u3057\u3066\u3001\u3088\u308a\u76f4\u611f\u7684\u306a\u578b\u30ca\u30ed\u30fc\u30a4\u30f3\u30b0\u304c\u53ef\u80fd\u306b<\/p>\n<p id=\"gh8VurQS0J\">\u4e0a\u8a18\u306e\u3046\u3061\u3001\u672c\u8a18\u4e8b\u3067\u306fwarnings.deprecated()\u3068typing.ReadOnly\u3092\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>warnings.deprecated()\u30c7\u30b3\u30ec\u30fc\u30bf<\/p>\n<p id=\"ghbeDuAVtn\">Python\u3067\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u308b\u3068\u3001\u3042\u308b\u95a2\u6570\u3084\u30af\u30e9\u30b9\u306a\u3069\u304c\u5c06\u6765\u7684\u306b\u5ec3\u6b62\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u3001\u975e\u63a8\u5968\u3067\u3042\u308b\u3053\u3068\u3092\u5229\u7528\u8005\u306b\u77e5\u3089\u305b\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002Python 3.12\u4ee5\u524d\u3067\u306f\u95a2\u6570\u3084\u30af\u30e9\u30b9\u306e\u975e\u63a8\u5968\u8b66\u544a\u3092\u3059\u308b\u306b\u306fwarnings.warn()\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u95a2\u6570\u3084\u30af\u30e9\u30b9\u5185\u306b\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3057\u305f\u30023.13\u304b\u3089\u306fwarnings.deprecated()\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u884c\u3048\u307e\u3059\u3002\u5177\u4f53\u7684\u306a\u4f7f\u3044\u65b9\u306f\u5f8c\u8ff0\u3057\u307e\u3059\u304c\u3001\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<p id=\"gh7ooFa0Y0\">\u4ee5\u4e0b\u304c\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002\u30b3\u30e1\u30f3\u30c8\u30673.12\u4ee5\u524d\u306e\u8a18\u8ff0\u65b9\u6cd5\u3082\u8a18\u8f09\u3057\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30b9\u30c8 example_warn.py\uff1awarnings.deprecated()\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u30b5\u30f3\u30d7\u30eb<br \/>\nimport warnings<\/p>\n<p>@warnings.deprecated(&#8220;Use `new_func()` instead.&#8221;)<br \/>\ndef old_func():<\/p>\n<p>    return &#8220;result (old)&#8221;<\/p>\n<p>def new_func():<br \/>\n    return &#8220;result(new)&#8221;<\/p>\n<p>print(old_func())  <\/p>\n<p id=\"ghegsNNbl1\">\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>$ python3.13 example_warn.py<br \/>\n\/home\/ubuntu\/example_warn.py:15: DeprecationWarning: Use `new_func()` instead.<br \/>\n  print(old_func())  # \u5b9f\u884c\u6642\u306b\u8b66\u544a<br \/>\nresult (old)<\/p>\n<p id=\"ghcoNwwK6r\">warnings.deprecated()\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u3001 Mypy\u306a\u3069\u306e\u578b\u30c1\u30a7\u30c3\u30ab\u30fc\u3067\u3082\u975e\u63a8\u5968\u3092\u78ba\u8a8d\u3067\u304d\u308b\u70b9\u304c\u3042\u308a\u307e\u3059\u3002Mypy 1.14\u4ee5\u964d\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b&#8211;enable-error-code=deprecated\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30c1\u30a7\u30c3\u30af\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>mypy example_warn.py &#8211;enable-error-code=deprecated<br \/>\nexample_warn.py:15: error: function example_warn.old_func is deprecated: Use `new_func()` instead.  [deprecated]<br \/>\nFound 1 error in 1 file (checked 1 source file)<\/p>\n<p>typing.ReadOnly\u3067\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306e\u8981\u7d20\u3092\u5b9a\u7fa9<\/p>\n<p id=\"gh7QTRlDxM\">Python 3.12\u4ee5\u524d\u3067\u306f\u3001TypedDict\u306e\u5024\u306f\u53ef\u5909\u3067\u3001\u578b\u30b7\u30b9\u30c6\u30e0\u4e0a\u3067\u5909\u66f4\u3092\u9632\u3050\u624b\u6bb5\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002Python 3.13\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001TypedDict\u306e\u4e00\u90e8\u306e\u30ad\u30fc\u306e\u5024\u304c\u5909\u66f4\u4e0d\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092ReadOnly\u3092\u4f7f\u7528\u3057\u3066\u5b9a\u7fa9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u30ea\u30b9\u30c8 example_readonly.py\uff1aTypedDict\u306e\u30ad\u30fc\u3092ReadOnly\u306b\u3059\u308b\u30b5\u30f3\u30d7\u30eb<br \/>\nfrom typing import TypedDict, ReadOnly<\/p>\n<p>class Lang(TypedDict):<br \/>\n    name: ReadOnly[str]<br \/>\n    age: int  <\/p>\n<p>lang: Lang = {&#8220;name&#8221;: &#8220;Python&#8221;, &#8220;age&#8221;: 34}<\/p>\n<p>lang[&#8220;age&#8221;] = 35<br \/>\nlang[&#8220;name&#8221;] = &#8220;Rust&#8221;  <\/p>\n<p id=\"gh5TvhVoRJ\">Mypy\u3092\u4f7f\u7528\u3057\u305f\u578b\u30c1\u30a7\u30c3\u30af\u306b\u304a\u3044\u3066\u3082\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bReadOnly TypedDict key\u3068\u30a8\u30e9\u30fc\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>$ mypy example_readonly.py<br \/>\nexample_readonly.py:12: error: ReadOnly TypedDict key &#8220;name&#8221; TypedDict is mutated  [typeddict-readonly-mutated]<br \/>\nFound 1 error in 1 file (checked 1 source file)<\/p>\n<p id=\"gh79ZfPJHm\">\u578b\u30d2\u30f3\u30c8\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306f\u4e00\u898b\u3059\u308b\u3068\u5c0f\u3055\u306a\u5909\u66f4\u306b\u601d\u3048\u307e\u3059\u304c\u3001\u3053\u308c\u307e\u3067\u5bfe\u5fdc\u3057\u304d\u308c\u306a\u304b\u3063\u305f\u90e8\u5206\u304c\u6539\u5584\u3055\u308c\u4f7f\u3044\u3084\u3059\u304f\u306a\u3063\u3066\u304a\u308a\u3001\u9032\u5316\u3092\u5b9f\u611f\u3067\u304d\u308b\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8<\/p>\n<p id=\"gh7ZLck84W\">\u3053\u3053\u304b\u3089\u306f\u7b46\u8005\u304c\u500b\u4eba\u7684\u306b\u9078\u3076\u300c\u4e3b\u8981\u306a\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306e\u9670\u306b\u96a0\u308c\u304c\u3061\u3060\u3051\u3069\u3001\u77e5\u3063\u3066\u304a\u304d\u305f\u3044\u300d\u5185\u5bb9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>os.process_cpu_count() \u95a2\u6570<\/p>\n<p id=\"gh8ayWxRNC\">1\u3064\u76ee\u306f\u3001os\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u8ffd\u52a0\u3055\u308c\u305fprocess_cpu_count()\u95a2\u6570\u306b\u3064\u3044\u3066\u3067\u3059\u3002<\/p>\n<p id=\"gh6ULeQqgw\">process_cpu_count()\u306f\u3001\u73fe\u5728\u5b9f\u884c\u4e2d\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u4f7f\u7528\u3067\u304d\u308bCPU\u306e\u8ad6\u7406\u30b3\u30a2\u6570\u3092\u8fd4\u3059\u95a2\u6570\u3067\u3059\u3002\u3053\u308c\u307e\u3067\u3082cpu_count()\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u3067\u5229\u7528\u53ef\u80fd\u306aCPU\u30b3\u30a2\u6570\u3092\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u304c\u3001process_cpu_count()\u95a2\u6570\u3067\u306f\u30b7\u30b9\u30c6\u30e0\u306eCPU\u30ea\u30bd\u30fc\u30b9\u3092\u52d5\u7684\u306b\u78ba\u8a8d\u3067\u304d\u308b\u305f\u3081\u3001\u4e26\u5217\u51e6\u7406\u3092\u884c\u3046\u969b\u306b\u3001\u3069\u306e\u7a0b\u5ea6\u306e\u4e26\u5217\u3092\u4f7f\u3046\u3079\u304d\u304b\u306e\u8abf\u6574\u304c\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>&gt;&gt;&gt; import os<br \/>\n&gt;&gt;&gt; print(os.process_cpu_count())<br \/>\n4<\/p>\n<p>copy.replace() \u95a2\u6570<\/p>\n<p id=\"gh5ZiLEt_q\">2\u3064\u76ee\u3082\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u304b\u3089\u3067\u3059\u304c\u3001copy\u30e2\u30b8\u30e5\u30fc\u30eb\u306breplace()\u95a2\u6570\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002\u4e3b\u306a\u7528\u9014\u3068\u3057\u3066\u306f\u3001\u300c\u2060\u65e2\u5b58\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5909\u66f4\u3057\u3001\u65b0\u3057\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u305f\u3044\u5834\u5408\u300d\u304c\u60f3\u5b9a\u3055\u308c\u307e\u3059\u3002copy.replace()\u95a2\u6570\u306e\u30b5\u30dd\u30fc\u30c8\u306b\u306f\u3001\u4ee5\u4e0b\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>collections.namedtuple()<br \/>\ndataclasses.dataclass<br \/>\ndatetime.datetime, datetime.date, datetime.time<\/p>\n<p id=\"ghelTx0AWx\">\u3053\u308c\u307e\u3067\u3082namedtuple\u306b\u306f_replace()\u95a2\u6570\u3001dataclass\u3068datetime\u306b\u306freplace()\u95a2\u6570\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u7570\u306a\u308b\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u3001\u305d\u308c\u305e\u308c\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u5206\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001isinstance()\u95a2\u6570\u306a\u3069\u3092\u7528\u3044\u3066\u51e6\u7406\u306e\u5206\u5c90\u304c\u5fc5\u8981\u3067\u3057\u305f\u3002<\/p>\n<p id=\"ghaD9QbsH8\">copy.replace()\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u308c\u3089\u3092\u7d71\u4e00\u7684\u306b\u6271\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30b9\u30c8 example_copy.py\uff1acopy.replace()\u306e\u30b5\u30f3\u30d7\u30eb<br \/>\nimport copy<br \/>\nfrom dataclasses import dataclass<br \/>\nfrom collections import namedtuple<br \/>\nfrom datetime import datetime, date<\/p>\n<p>@dataclass(frozen=True)<br \/>\nclass LangData:<br \/>\n    name: str<br \/>\n    birth: datetime<\/p>\n<p>py_data = LangData(name=&#8221;Python&#8221;, birth=datetime(1991, 2, 20))<br \/>\nru_data = LangData(name=&#8221;Rust&#8221;, birth=datetime(2015, 5, 15))<\/p>\n<p>py_data2 = copy.replace(py_data, birth=copy.replace(py_data.birth, year=2000))<\/p>\n<p>print(py_data2)  <\/p>\n<p>LangTuple = namedtuple(&#8220;LangTuple&#8221;, [&#8220;name&#8221;, &#8220;birth&#8221;])<\/p>\n<p>py_tuple = LangTuple(name=&#8221;Python&#8221;, birth=date(1991, 2, 20))<br \/>\nru_tuple = LangTuple(name=&#8221;Rust&#8221;, birth=date(2015, 5, 15))<\/p>\n<p>ru_tuple2 = copy.replace(ru_tuple, birth=copy.replace(ru_tuple.birth, year=2020))<\/p>\n<p>print(ru_tuple2)  <\/p>\n<p>dt1 = datetime(2025, 2, 20, 14, 30)<br \/>\ndt2 = copy.replace(dt1, year=2030)<br \/>\nprint(dt2)  <\/p>\n<p>\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u30b5\u30dd\u30fc\u30c8<\/p>\n<p id=\"gh6YkAKAPC\">3\u3064\u76ee\u306f\u3001Python\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u30b5\u30dd\u30fc\u30c8\u306b\u3064\u3044\u3066\u3067\u3059\u3002Python\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306f\u300cTier\u300d\u3068\u3044\u3046\u30ab\u30c6\u30b4\u30ea\u306b\u5206\u3051\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u30ec\u30d9\u30eb\u304c\u9ad8\u3044\u65b9\u304b\u3089Tier 1\u3001Tier 2\u3001Tier 3\u306b\u5206\u3051\u3089\u308c\u3066\u304a\u308a\u3001Tier 1\u304c\u6700\u3082\u30b5\u30dd\u30fc\u30c8\u30ec\u30d9\u30eb\u304c\u9ad8\u3044\u30ab\u30c6\u30b4\u30ea\u30fc\u3067\u3059[1]\u3002<\/p>\n<p id=\"gheYA25wHs\">[1] \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u30b5\u30dd\u30fc\u30c8\u306b\u3064\u3044\u3066\u306fPEP 11\u3067\u5c0e\u5165\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u8a73\u3057\u304f\u77e5\u308a\u305f\u3044\u65b9\u306fPEP 11\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<p id=\"gheg_2GLsZ\">Python 3.13\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u30b5\u30dd\u30fc\u30c8\u306e\u66f4\u65b0\u304c\u884c\u308f\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>Apple\u306eiOS\u3068Android\u304cTier 3\u306b\u8ffd\u52a0\u3055\u308c\u3001\u516c\u5f0f\u30b5\u30dd\u30fc\u30c8\u5bfe\u8c61\u306b<br \/>\nwasm32-wasi\uff08WASM\uff08WebAssembly\uff09\u5411\u3051\u306e WASI\uff08WebAssembly System Interface\u2060\uff09\u2060\uff09\u304c Tier 2\u306b\u6607\u683c<\/p>\n<p id=\"gh6L3H6l2_\">1.\u306b\u3064\u3044\u3066\u306f\u3001\u3044\u305a\u308c\u3082\u307e\u3060\u5236\u7d04\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u30e2\u30d0\u30a4\u30ebOS\u4e0a\u3067Python\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u52d5\u4f5c\u3059\u308b\u74b0\u5883\u304c\u7740\u5b9f\u306b\u6574\u3044\u59cb\u3081\u3066\u3044\u308b\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u30022.\u306b\u3064\u3044\u3066\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u5916\u3067WebAssembly\u3092\u4f7f\u3046\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u74b0\u5883\u3067\u3001Python\u306e\u5229\u7528\u304c\u3055\u3089\u306b\u3057\u3084\u3059\u304f\u306a\u308b\u3053\u3068\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002\u4e00\u65b9\u3067\u3001Web\u30d6\u30e9\u30a6\u30b6\u3067Python\u3092\u52d5\u304b\u3059\u305f\u3081Emscripten\u3092\u4f7f\u7528\u3057\u305fWebAssembly wasm32-emscripten\u306f\u3001\u516c\u5f0f\u30b5\u30dd\u30fc\u30c8\u5916\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u3053\u306e\u3042\u305f\u308a\u306f\u3001\u4eca\u5f8c\u306e\u52d5\u5411\u304c\u6c17\u306b\u306a\u308b\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p>\u307e\u3068\u3081<\/p>\n<p id=\"gh1Bb4j3Sk\">\u4eca\u56de\u306fPython 3.13\u306e\u30ea\u30ea\u30fc\u30b9\u304b\u3089\u6ce8\u76ee\u3055\u308c\u308b\u90e8\u5206\u3092\u4e2d\u5fc3\u306b\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316\u3001\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6539\u5584\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u5f37\u5316\u306a\u3069\u591a\u304f\u306e\u9032\u5316\u304c\u898b\u3089\u308c\u3001\u7279\u306bJIT\u306e\u8a66\u9a13\u5c0e\u5165\u306a\u3069\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u901f\u5ea6\u5411\u4e0a\u306b\u95a2\u3057\u3066\u306f\u5177\u4f53\u7684\u306a\u53d6\u308a\u7d44\u307f\u304c\u9032\u3093\u3067\u3044\u307e\u3059\u3002<\/p>\n<p id=\"gh6DBDo6S4\">\u307e\u305f\u3001Python 3.13\u3067\u306f\u3001PEP 602\u306b\u57fa\u3065\u3044\u305f\u5e74\u6b21\u30ea\u30ea\u30fc\u30b9\u30b5\u30a4\u30af\u30eb\u3082\u66f4\u65b0\u3055\u308c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5909\u66f4\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u30d5\u30eb\u30b5\u30dd\u30fc\u30c8\uff08\u30d0\u30b0\u4fee\u6b63\uff09\u306e\u671f\u9593\u304c\u5f93\u6765\u306e1\u5e74\u534a\u304b\u30892\u5e74\u306b\u5ef6\u9577<br \/>\n\u305d\u306e\u5f8c\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30d5\u30a3\u30c3\u30af\u30b9\u306e\u671f\u9593\u306f3\u5e74\u306b\u5909\u66f4<\/p>\n<p id=\"gh3Cv4MSFz\">\u3053\u306e\u5909\u66f4\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30d0\u30b0\u4fee\u6b63\u3092\u53d7\u3051\u3089\u308c\u308b\u671f\u9593\u304c\u9577\u304f\u306a\u308a\u3001\u3088\u308a\u5b89\u5b9a\u3057\u305f\u74b0\u5883\u3067\u9577\u304f\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3053\u3068\u3082\u5b09\u3057\u3044\u3053\u3068\u3067\u3059\u3002\u4eca\u5f8c\u306e\u30ea\u30ea\u30fc\u30b9\u306b\u3082\u671f\u5f85\u3057\u3064\u3064\u3001\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306ePython\u3092\u6d3b\u7528\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9580\u8107\uff08@satoru_kadowaki\uff09\u3067\u3059\u30022025\u5e742\u6708\u306e\u300cPython Monthly Topics\u300d\u306f\u3001Python 3.13\u3067\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3055\u308c\u305f\u6a5f\u80fd\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u3054\u5b58\u77e5\u306e\u3088\u3046\u306b\u3001Python 3.13\u306f<\/p>\n","protected":false},"author":2,"featured_media":2439111,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[762827],"tags":[763397,43839,781035,762834,762833,521918,781036,162246,763396,2662,762832],"class_list":{"0":"post-2439110","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-science-technology","8":"tag-gihyo-jp","9":"tag-python","10":"tag-python-3-13","11":"tag-science-technology","12":"tag-science-news","13":"tag-technology-news","14":"tag-781036","15":"tag-162246","16":"tag-763396","17":"tag-2662","18":"tag-762832"},"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/posts\/2439110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/comments?post=2439110"}],"version-history":[{"count":0,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/posts\/2439110\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/media\/2439111"}],"wp:attachment":[{"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/media?parent=2439110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/categories?post=2439110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wacoca.com\/news\/wp-json\/wp\/v2\/tags?post=2439110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}