diff --git a/Lib/sqlite3/__main__.py b/Lib/sqlite3/__main__.py index c2fa23c46cf990..471273b32131f8 100644 --- a/Lib/sqlite3/__main__.py +++ b/Lib/sqlite3/__main__.py @@ -7,9 +7,7 @@ import sqlite3 import sys -from argparse import ArgumentParser from code import InteractiveConsole -from textwrap import dedent from _colorize import get_theme, theme_no_color @@ -80,6 +78,9 @@ def runsource(self, source, filename="", symbol="single"): def main(*args): + from argparse import ArgumentParser + from textwrap import dedent + parser = ArgumentParser( description="Python sqlite3 CLI", color=True, diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 0315760516edf8..53cafad41a2fe3 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -21,7 +21,6 @@ # 3. This notice may not be removed or altered from any source distribution. import datetime -import time import collections.abc from _sqlite3 import * @@ -37,12 +36,15 @@ Timestamp = datetime.datetime def DateFromTicks(ticks): + import time # Lazy, to improve import time return Date(*time.localtime(ticks)[:3]) def TimeFromTicks(ticks): + import time # Lazy, to improve import time return Time(*time.localtime(ticks)[3:6]) def TimestampFromTicks(ticks): + import time # Lazy, to improve import time return Timestamp(*time.localtime(ticks)[:6]) @@ -52,6 +54,8 @@ def TimestampFromTicks(ticks): collections.abc.Sequence.register(Row) def register_adapters_and_converters(): + global _lazy_register + _lazy_register = lambda: None # Prevent multiple registration # noqa: E731 from warnings import warn msg = ("The default {what} is deprecated as of Python 3.12; " diff --git a/Misc/NEWS.d/next/Library/2025-01-21-14-51-44.gh-issue-118761.Z0F-d5.rst b/Misc/NEWS.d/next/Library/2025-01-21-14-51-44.gh-issue-118761.Z0F-d5.rst new file mode 100644 index 00000000000000..eab19174b21825 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-21-14-51-44.gh-issue-118761.Z0F-d5.rst @@ -0,0 +1 @@ +Improve the import time of :mod:`sqlite3` by 1.5x faster. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy