mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-118761: Improve import time for csv
(#128858)
This reduces the import time of the `csv` module by up to five times, by importing `re` on demand. In particular, the `re` module is no more implicitly exposed as `csv.re`.
This commit is contained in:
parent
d3adf02c90
commit
d5e9aa690a
2 changed files with 4 additions and 1 deletions
|
@ -63,7 +63,6 @@ SETTINGS:
|
|||
written as two quotes
|
||||
"""
|
||||
|
||||
import re
|
||||
import types
|
||||
from _csv import Error, writer, reader, register_dialect, \
|
||||
unregister_dialect, get_dialect, list_dialects, \
|
||||
|
@ -281,6 +280,7 @@ class Sniffer:
|
|||
If there is no quotechar the delimiter can't be determined
|
||||
this way.
|
||||
"""
|
||||
import re
|
||||
|
||||
matches = []
|
||||
for restr in (r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)', # ,".*?",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue