Skip to content

Instantly share code, notes, and snippets.

@jaraco
Created April 9, 2024 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaraco/6a98a4d0cba31c93c0264154d75c3089 to your computer and use it in GitHub Desktop.
Save jaraco/6a98a4d0cba31c93c0264154d75c3089 to your computer and use it in GitHub Desktop.
cpython gh-117348/import-perf @ ./python.exe -X importtime -c 'import configparser' 2>1 | grep -E '(cumul|configparser)'
import time: self [us] | cumulative | imported package
import time: 7573 | 15790 | configparser
cpython gh-117348/import-perf @ ./python.exe -X importtime -c 'import configparser' 2>1 | grep -E '(cumul|configparser)'
import time: self [us] | cumulative | imported package
import time: 1760 | 10852 | configparser
cpython gh-117348/import-perf @ git stash pop
On branch gh-117348/import-perf
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Lib/configparser.py
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (8dfe3a6662fbbadd31733799362a11ee667ba474)
cpython gh-117348/import-perf @ git diff
diff --git a/Lib/configparser.py b/Lib/configparser.py
index ca9fef532b..91e2b9299a 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -146,13 +146,13 @@
from collections.abc import Iterable, MutableMapping
from collections import ChainMap as _ChainMap
import contextlib
-from dataclasses import dataclass, field
import functools
import io
import itertools
import os
import re
import sys
+import types
__all__ = ("NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
"NoOptionError", "InterpolationError", "InterpolationDepthError",
@@ -537,19 +537,21 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
"found: %r" % (rest,))
-@dataclass
-class _ReadState:
- elements_added : set[str] = field(default_factory=set)
+class _ReadState(types.SimpleNamespace):
+ elements_added : set[str]
cursect : dict[str, str] | None = None
sectname : str | None = None
optname : str | None = None
lineno : int = 0
indent_level : int = 0
- errors : list[ParsingError] = field(default_factory=list)
+ errors : list[ParsingError]
+ def __init__(self):
+ self.elements_added = set()
+ self.errors = list()
-@dataclass
-class _Prefixes:
+
+class _Prefixes(types.SimpleNamespace):
full : Iterable[str]
inline : Iterable[str]
cpython gh-117348/import-perf @ ./python.exe -X importtime -c 'import configparser' 2>1 | grep -E '(cumul|configparser)'
import time: self [us] | cumulative | imported package
import time: 6934 | 10799 | configparser
cpython gh-117348/import-perf @ ./python.exe -X importtime -c 'import configparser' 2>1 | grep -E '(cumul|configparser)'
import time: self [us] | cumulative | imported package
import time: 967 | 4339 | configparser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment