Skip to content

gh-118761: Improve import time of sqlite3 #129118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/sqlite3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

"""
The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compliant
interface to the SQLite library, and requires SQLite 3.7.15 or newer.
interface to the SQLite library, and requires SQLite 3.15.2 or newer.

To use the module, start by creating a database Connection object:

Expand Down
6 changes: 3 additions & 3 deletions Lib/sqlite3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"""
import sqlite3
import sys

from argparse import ArgumentParser
from code import InteractiveConsole
from textwrap import dedent


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


def main(*args):
from argparse import ArgumentParser
from textwrap import dedent

parser = ArgumentParser(
description="Python sqlite3 CLI",
)
Expand Down
6 changes: 4 additions & 2 deletions Lib/sqlite3/dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.

import datetime
import time
import collections.abc
import datetime

from _sqlite3 import *

Expand All @@ -37,12 +36,15 @@
Timestamp = datetime.datetime

def DateFromTicks(ticks):
import time
return Date(*time.localtime(ticks)[:3])

def TimeFromTicks(ticks):
import time
return Time(*time.localtime(ticks)[3:6])

def TimestampFromTicks(ticks):
import time
return Timestamp(*time.localtime(ticks)[:6])


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve import time of :mod:`sqlite3` by around 2 times. Patch by Jiahao Li.
Loading