-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-137855: Improve import time of sqlite3
#131796
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
Changes from 1 commit
4b04bdf
d3cf658
4373d47
def1974
04eedab
ccf3575
4c138d8
f434be3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,6 @@ | |
| import sqlite3 | ||
| import sys | ||
|
|
||
| from argparse import ArgumentParser | ||
| from code import InteractiveConsole | ||
| from textwrap import dedent | ||
|
|
||
|
|
||
| def execute(c, sql, suppress_errors=True): | ||
| """Helper that wraps execution of SQL code. | ||
|
|
@@ -34,13 +30,15 @@ def execute(c, sql, suppress_errors=True): | |
| sys.exit(1) | ||
|
|
||
|
|
||
| class SqliteInteractiveConsole(InteractiveConsole): | ||
| class SqliteInteractiveConsole: | ||
| """A simple SQLite REPL.""" | ||
|
|
||
| def __init__(self, connection): | ||
| super().__init__() | ||
| from code import InteractiveConsole | ||
| self._con = connection | ||
| self._cur = connection.cursor() | ||
| self._console = InteractiveConsole() | ||
| self._console.runsource = self.runsource | ||
|
|
||
| def runsource(self, source, filename="<input>", symbol="single"): | ||
| """Override runsource, the core of the InteractiveConsole REPL. | ||
|
|
@@ -61,8 +59,14 @@ def runsource(self, source, filename="<input>", symbol="single"): | |
| execute(self._cur, source) | ||
| return False | ||
|
|
||
| def interact(self, banner, exitmsg=""): | ||
| self._console.interact(banner, exitmsg=exitmsg) | ||
|
|
||
|
|
||
| def main(*args): | ||
| from argparse import ArgumentParser | ||
| from textwrap import dedent | ||
|
|
||
|
Comment on lines
86
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see a valid reason to do code churn and delay imports for the sake of speeding up
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume the following:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The REPL is of course part of calling User code certainly could import
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @eli-schwartz. This change looks meaningless. |
||
| parser = ArgumentParser( | ||
| description="Python sqlite3 CLI", | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Halve the import time of :mod:`sqlite3`. | ||
| Improve the import time of :mod:`sqlite3` by 1.5x faster. |
Uh oh!
There was an error while loading. Please reload this page.