Skip to content

Commit 2830c65

Browse files
committed
Improve import time of sqlite3
1 parent e65a1eb commit 2830c65

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

Lib/sqlite3/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# pysqlite2/__init__.py: the pysqlite2 package.
1+
# sqlite3/__init__.py: the sqlite3 package.
22
#
33
# Copyright (C) 2005 Gerhard Häring <[email protected]>
44
#
5-
# This file is part of pysqlite.
5+
# This file is part of sqlite3.
66
#
77
# This software is provided 'as-is', without any express or implied
88
# warranty. In no event will the authors be held liable for any damages
@@ -22,7 +22,7 @@
2222

2323
"""
2424
The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compliant
25-
interface to the SQLite library, and requires SQLite 3.7.15 or newer.
25+
interface to the SQLite library, and requires SQLite 3.15.2 or newer.
2626
2727
To use the module, start by creating a database Connection object:
2828

Lib/sqlite3/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"""
77
import sqlite3
88
import sys
9-
10-
from argparse import ArgumentParser
119
from code import InteractiveConsole
12-
from textwrap import dedent
1310

1411

1512
def execute(c, sql, suppress_errors=True):
@@ -63,6 +60,9 @@ def runsource(self, source, filename="<input>", symbol="single"):
6360

6461

6562
def main(*args):
63+
from argparse import ArgumentParser
64+
from textwrap import dedent
65+
6666
parser = ArgumentParser(
6767
description="Python sqlite3 CLI",
6868
)

Lib/sqlite3/dbapi2.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pysqlite2/dbapi2.py: the DB-API 2.0 interface
1+
# sqlite3/dbapi2.py: the DB-API 2.0 interface
22
#
33
# Copyright (C) 2004-2005 Gerhard Häring <[email protected]>
44
#
@@ -20,11 +20,10 @@
2020
# misrepresented as being the original software.
2121
# 3. This notice may not be removed or altered from any source distribution.
2222

23-
import datetime
24-
import time
2523
import collections.abc
24+
import datetime
2625

27-
from _sqlite3 import *
26+
from _sqlite3 import Row, sqlite_version
2827

2928
paramstyle = "qmark"
3029

@@ -37,12 +36,15 @@
3736
Timestamp = datetime.datetime
3837

3938
def DateFromTicks(ticks):
39+
import time
4040
return Date(*time.localtime(ticks)[:3])
4141

4242
def TimeFromTicks(ticks):
43+
import time
4344
return Time(*time.localtime(ticks)[3:6])
4445

4546
def TimestampFromTicks(ticks):
47+
import time
4648
return Timestamp(*time.localtime(ticks)[:6])
4749

4850

@@ -52,6 +54,7 @@ def TimestampFromTicks(ticks):
5254
collections.abc.Sequence.register(Row)
5355

5456
def register_adapters_and_converters():
57+
from _sqlite3 import register_adapter, register_converter
5558
from warnings import warn
5659

5760
msg = ("The default {what} is deprecated as of Python 3.12; "
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve import time of :mod:`sqlite3` by around 2 times. Patch by Jiahao Li.

0 commit comments

Comments
 (0)