Skip to content

gh-118761: Improve import time for csv #128858

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

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all 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/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class excel:
written as two quotes
"""

import re
import types
from _csv import Error, writer, reader, register_dialect, \
unregister_dialect, get_dialect, list_dialects, \
Expand Down Expand Up @@ -281,6 +280,7 @@ def _guess_quote_and_delimiter(self, data, delimiters):
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)', # ,".*?",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reduce the import time of :mod:`csv` by up to five times, by importing
:mod:`re` on demand. In particular, ``re`` is no more implicitly exposed
as ``csv.re``. Patch by Bénédikt Tran.
Loading