From ec4d89e5d6d4c6a44db6b7da2f830ccc0591792b Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 30 Aug 2019 16:31:50 -0700 Subject: [PATCH 1/7] cleanup unnecessary comma --- pandas/core/dtypes/dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index ee1866e60644b..aa7e6801ba431 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -23,7 +23,7 @@ ordered_sentinel = object() # type: object -def register_extension_dtype(cls: Type[ExtensionDtype],) -> Type[ExtensionDtype]: +def register_extension_dtype(cls: Type[ExtensionDtype]) -> Type[ExtensionDtype]: """ Register an ExtensionType with pandas as class decorator. From 47b6de74eee958db04ddc436ffb93edfe8f3e200 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 30 Aug 2019 16:33:31 -0700 Subject: [PATCH 2/7] remove trailing comma --- pandas/util/_test_decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index 627757aaa3741..0e07b9f5fe9f7 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -102,7 +102,7 @@ def _skip_if_no_scipy(): ) -def skip_if_installed(package: str,) -> Callable: +def skip_if_installed(package: str) -> Callable: """ Skip a test if a package is installed. From ed992bc908e4d098cdf6715fc2cb04792b64b239 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 30 Aug 2019 18:10:08 -0700 Subject: [PATCH 3/7] benchmark for import --- asv_bench/benchmarks/package.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 asv_bench/benchmarks/package.py diff --git a/asv_bench/benchmarks/package.py b/asv_bench/benchmarks/package.py new file mode 100644 index 0000000000000..1eca17f3df376 --- /dev/null +++ b/asv_bench/benchmarks/package.py @@ -0,0 +1,23 @@ +""" +Benchmarks for pandas at the package-level. +""" +import subprocess +import sys + +from pandas.compat import PY37 + +class TimeImport: + def time_import(self): + if PY37: + cmd = [sys.executable, "-X", "importtime", "-c", 'import pandas as pd'] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + _, stderr = p.communicate() + + line = stderr.splitlines()[-1] + field = line.split(b'|')[-2].strip() + total = int(field) # microseconds + return total + + cmd = [sys.executable, "-c", 'import pandas as pd'] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p.communicate() From 015e2700ab186125eabdf57ac9f6552fa85de73c Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 30 Aug 2019 18:14:39 -0700 Subject: [PATCH 4/7] double quotes --- asv_bench/benchmarks/package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/asv_bench/benchmarks/package.py b/asv_bench/benchmarks/package.py index 1eca17f3df376..73c14fdb291df 100644 --- a/asv_bench/benchmarks/package.py +++ b/asv_bench/benchmarks/package.py @@ -9,15 +9,15 @@ class TimeImport: def time_import(self): if PY37: - cmd = [sys.executable, "-X", "importtime", "-c", 'import pandas as pd'] + cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) _, stderr = p.communicate() line = stderr.splitlines()[-1] - field = line.split(b'|')[-2].strip() + field = line.split(b"|")[-2].strip() total = int(field) # microseconds return total - cmd = [sys.executable, "-c", 'import pandas as pd'] + cmd = [sys.executable, "-c", "import pandas as pd"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.communicate() From 72aeb48fc5c031c6fe7098575e7e8e5611b7f405 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 30 Aug 2019 18:15:01 -0700 Subject: [PATCH 5/7] missing whitespce --- asv_bench/benchmarks/package.py | 1 + 1 file changed, 1 insertion(+) diff --git a/asv_bench/benchmarks/package.py b/asv_bench/benchmarks/package.py index 73c14fdb291df..bd9752536f580 100644 --- a/asv_bench/benchmarks/package.py +++ b/asv_bench/benchmarks/package.py @@ -6,6 +6,7 @@ from pandas.compat import PY37 + class TimeImport: def time_import(self): if PY37: From b06cb1b8bf86a912ada8f88a7c3abf74938d4e21 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 2 Sep 2019 19:10:16 -0700 Subject: [PATCH 6/7] use subprocess.run --- asv_bench/benchmarks/package.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/asv_bench/benchmarks/package.py b/asv_bench/benchmarks/package.py index bd9752536f580..a04c06ed04882 100644 --- a/asv_bench/benchmarks/package.py +++ b/asv_bench/benchmarks/package.py @@ -11,14 +11,12 @@ class TimeImport: def time_import(self): if PY37: cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - _, stderr = p.communicate() + p = subprocess.run(cmd, stderr=subprocess.PIPE) - line = stderr.splitlines()[-1] + line = p.stderr.splitlines()[-1] field = line.split(b"|")[-2].strip() total = int(field) # microseconds return total cmd = [sys.executable, "-c", "import pandas as pd"] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - p.communicate() + p = subprocess.run(cmd, stderr=subprocess.PIPE) From a5d9eb27cfbb785a0eee0d4c1ad4be36870320e8 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 4 Sep 2019 09:58:29 -0700 Subject: [PATCH 7/7] comment --- asv_bench/benchmarks/package.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/package.py b/asv_bench/benchmarks/package.py index a04c06ed04882..8ca33db361fa0 100644 --- a/asv_bench/benchmarks/package.py +++ b/asv_bench/benchmarks/package.py @@ -10,6 +10,9 @@ class TimeImport: def time_import(self): if PY37: + # on py37+ we the "-X importtime" usage gives us a more precise + # measurement of the import time we actually care about, + # without the subprocess or interpreter overhead cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"] p = subprocess.run(cmd, stderr=subprocess.PIPE) @@ -19,4 +22,4 @@ def time_import(self): return total cmd = [sys.executable, "-c", "import pandas as pd"] - p = subprocess.run(cmd, stderr=subprocess.PIPE) + subprocess.run(cmd, stderr=subprocess.PIPE)