Skip to content

Commit 6a7ba96

Browse files
jbrockmendelWillAyd
authored andcommitted
PERF: asv for import (#28239)
1 parent 0bde7ce commit 6a7ba96

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

asv_bench/benchmarks/package.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Benchmarks for pandas at the package-level.
3+
"""
4+
import subprocess
5+
import sys
6+
7+
from pandas.compat import PY37
8+
9+
10+
class TimeImport:
11+
def time_import(self):
12+
if PY37:
13+
# on py37+ we the "-X importtime" usage gives us a more precise
14+
# measurement of the import time we actually care about,
15+
# without the subprocess or interpreter overhead
16+
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
17+
p = subprocess.run(cmd, stderr=subprocess.PIPE)
18+
19+
line = p.stderr.splitlines()[-1]
20+
field = line.split(b"|")[-2].strip()
21+
total = int(field) # microseconds
22+
return total
23+
24+
cmd = [sys.executable, "-c", "import pandas as pd"]
25+
subprocess.run(cmd, stderr=subprocess.PIPE)

pandas/core/dtypes/dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ordered_sentinel = object() # type: object
2424

2525

26-
def register_extension_dtype(cls: Type[ExtensionDtype],) -> Type[ExtensionDtype]:
26+
def register_extension_dtype(cls: Type[ExtensionDtype]) -> Type[ExtensionDtype]:
2727
"""
2828
Register an ExtensionType with pandas as class decorator.
2929

pandas/util/_test_decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _skip_if_no_scipy():
102102
)
103103

104104

105-
def skip_if_installed(package: str,) -> Callable:
105+
def skip_if_installed(package: str) -> Callable:
106106
"""
107107
Skip a test if a package is installed.
108108

0 commit comments

Comments
 (0)