From 9fc1238a9771b8e864010f8291cfc3113cf166a2 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 25 Apr 2025 11:49:53 -0400 Subject: [PATCH] gh-127648: Improve Python startup time by ~12% --- Lib/io.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/io.py b/Lib/io.py index e9fe619392e3d9..fadc19c09be424 100644 --- a/Lib/io.py +++ b/Lib/io.py @@ -53,7 +53,6 @@ import _io import abc -from _collections_abc import _check_methods from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation, open, open_code, FileIO, BytesIO, StringIO, BufferedReader, BufferedWriter, BufferedRWPair, BufferedRandom, @@ -126,6 +125,7 @@ def read(self, size=..., /): @classmethod def __subclasshook__(cls, C): if cls is Reader: + from _collections_abc import _check_methods return _check_methods(C, "read") return NotImplemented @@ -147,6 +147,7 @@ def write(self, data, /): @classmethod def __subclasshook__(cls, C): if cls is Writer: + from _collections_abc import _check_methods return _check_methods(C, "write") return NotImplemented