Skip to content

Commit 02e98c6

Browse files
committed
Use lazy imports on Python 3.15 to improve startup speed
1 parent 779a0dd commit 02e98c6

78 files changed

Lines changed: 202 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/PIL/AvifImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
__lazy_modules__ = {"io", "os", "typing"}
4+
35
import os
46
from io import BytesIO
57
from typing import IO

src/PIL/BdfFontFile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
from __future__ import annotations
2525

26+
__lazy_modules__ = {"typing"}
27+
2628
from typing import BinaryIO
2729

2830
from . import FontFile, Image

src/PIL/BlpImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
from __future__ import annotations
3333

34+
__lazy_modules__ = {"io", "os", "struct", "typing"}
35+
3436
import abc
3537
import os
3638
import struct

src/PIL/BmpImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#
2525
from __future__ import annotations
2626

27+
__lazy_modules__ = {"PIL._binary", "os", "typing"}
28+
2729
import os
2830
from typing import IO, Any
2931

src/PIL/BufrStubImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#
1111
from __future__ import annotations
1212

13+
__lazy_modules__ = {"os", "typing"}
14+
1315
import os
1416
from typing import IO
1517

src/PIL/ContainerIO.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#
1616
from __future__ import annotations
1717

18+
__lazy_modules__ = {"collections.abc", "io"}
19+
1820
import io
1921
from collections.abc import Iterable
2022
from typing import IO, AnyStr, NoReturn

src/PIL/CurImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#
1818
from __future__ import annotations
1919

20+
__lazy_modules__ = {"PIL._binary"}
21+
2022
from . import BmpImagePlugin, Image, ImageOps
2123
from ._binary import i16le as i16
2224
from ._binary import i32le as i32

src/PIL/DcxImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#
2323
from __future__ import annotations
2424

25+
__lazy_modules__ = {"PIL._binary", "PIL._util"}
26+
2527
from . import Image
2628
from ._binary import i32le as i32
2729
from ._util import DeferredError

src/PIL/DdsImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from __future__ import annotations
1414

15+
__lazy_modules__ = {"PIL._binary", "struct", "typing"}
16+
1517
import struct
1618
import sys
1719
from enum import IntEnum, IntFlag

src/PIL/EpsImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#
2222
from __future__ import annotations
2323

24+
__lazy_modules__ = {"PIL._binary", "io", "os", "subprocess", "tempfile", "typing"}
25+
2426
import io
2527
import os
2628
import re

0 commit comments

Comments
 (0)