Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fcbf7c9

Browse filesBrowse files
author
kylev
committed
"import" creates GIL overhead every time it is run. For threaded MySQLdb apps,
it doesn't make sense to pay that cost for every execute(), so lets move some of these imports. http://wiki.python.org/moin/PythonSpeed/PerformanceTips#ImportStatementOverhead
1 parent 4d70852 commit fcbf7c9
Copy full SHA for fcbf7c9

File tree

Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed

‎MySQLdb/MySQLdb/cursors.py

Copy file name to clipboardExpand all lines: MySQLdb/MySQLdb/cursors.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"""
77

88
import re
9+
import sys
10+
from types import ListType, TupleType, UnicodeType
11+
912

1013
restr = (r"\svalues\s*"
1114
r"(\(((?<!\\)'[^\)]*?\)[^\)]*(?<!\\)?'"
@@ -65,7 +68,7 @@ def __del__(self):
6568
self.close()
6669
self.errorhandler = None
6770
self._result = None
68-
71+
6972
def close(self):
7073
"""Close the cursor. No further queries will be possible."""
7174
if not self.connection: return
@@ -147,8 +150,6 @@ def execute(self, query, args=None):
147150
Returns long integer rows affected, if any
148151
149152
"""
150-
from types import ListType, TupleType
151-
from sys import exc_info
152153
del self.messages[:]
153154
db = self._get_db()
154155
charset = db.character_set_name()
@@ -167,7 +168,7 @@ def execute(self, query, args=None):
167168
self.messages.append((TypeError, m))
168169
self.errorhandler(self, TypeError, m)
169170
except:
170-
exc, value, tb = exc_info()
171+
exc, value, tb = sys.exc_info()
171172
del tb
172173
self.messages.append((exc, value))
173174
self.errorhandler(self, exc, value)
@@ -216,8 +217,7 @@ def executemany(self, query, args):
216217
else:
217218
self.errorhandler(self, TypeError, msg)
218219
except:
219-
from sys import exc_info
220-
exc, value, tb = exc_info()
220+
exc, value, tb = sys.exc_info()
221221
del tb
222222
self.errorhandler(self, exc, value)
223223
r = self._query('\n'.join([query[:p], ',\n'.join(q), query[e:]]))
@@ -254,7 +254,6 @@ def callproc(self, procname, args=()):
254254
disconnected.
255255
"""
256256

257-
from types import UnicodeType
258257
db = self._get_db()
259258
charset = db.character_set_name()
260259
for index, arg in enumerate(args):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.