Skip to content

Commit 2d997af

Browse files
committed
PERF: Fix performance benchmark suite so it runs on Python 3
1 parent 4677306 commit 2d997af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+259
-208
lines changed

asv_bench/asv.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// The Pythons you'd like to test against. If not provided, defaults
2727
// to the current version of Python used to run `asv`.
2828
// "pythons": ["2.7", "3.4"],
29-
"pythons": ["2.7"],
29+
"pythons": ["2.7", "3.4"],
3030

3131
// The matrix of dependencies to test. Each key is the name of a
3232
// package (in PyPI) and the values are version numbers. An empty

asv_bench/benchmarks/attrs_caching.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22

33

44
class getattr_dataframe_index(object):

asv_bench/benchmarks/binary_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22
import pandas.computation.expressions as expr
33

44

asv_bench/benchmarks/categoricals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22

33

44
class concat_categorical(object):

asv_bench/benchmarks/ctors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22

33

44
class frame_constructor_ndarray(object):

asv_bench/benchmarks/eval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from pandas_vb_common import *
2-
import pandas.computation.expressions as expr
1+
from .pandas_vb_common import *
32
import pandas as pd
3+
import pandas.computation.expressions as expr
44

55

66
class eval_frame_add_all_threads(object):

asv_bench/benchmarks/frame_ctor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22
try:
33
from pandas.tseries.offsets import *
44
except:
@@ -1657,7 +1657,7 @@ class frame_ctor_nested_dict_int64(object):
16571657
goal_time = 0.2
16581658

16591659
def setup(self):
1660-
self.data = dict(((i, dict(((j, float(j)) for j in xrange(100)))) for i in xrange(2000)))
1660+
self.data = dict(((i, dict(((j, float(j)) for j in range(100)))) for i in xrange(2000)))
16611661

16621662
def time_frame_ctor_nested_dict_int64(self):
16631663
DataFrame(self.data)

asv_bench/benchmarks/frame_methods.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22

33

44
class frame_apply_axis_1(object):
@@ -398,7 +398,7 @@ def time_frame_from_records_generator(self):
398398
self.df = DataFrame.from_records(self.get_data())
399399

400400
def get_data(self, n=100000):
401-
return ((x, (x * 20), (x * 100)) for x in xrange(n))
401+
return ((x, (x * 20), (x * 100)) for x in range(n))
402402

403403

404404
class frame_from_records_generator_nrows(object):
@@ -408,7 +408,7 @@ def time_frame_from_records_generator_nrows(self):
408408
self.df = DataFrame.from_records(self.get_data(), nrows=1000)
409409

410410
def get_data(self, n=100000):
411-
return ((x, (x * 20), (x * 100)) for x in xrange(n))
411+
return ((x, (x * 20), (x * 100)) for x in range(n))
412412

413413

414414
class frame_get_dtype_counts(object):
@@ -443,11 +443,11 @@ def g(self):
443443
pass
444444

445445
def h(self):
446-
for i in xrange(10000):
446+
for i in range(10000):
447447
self.df2['A']
448448

449449
def j(self):
450-
for i in xrange(10000):
450+
for i in range(10000):
451451
self.df3[0]
452452

453453

@@ -473,11 +473,11 @@ def g(self):
473473
pass
474474

475475
def h(self):
476-
for i in xrange(10000):
476+
for i in range(10000):
477477
self.df2['A']
478478

479479
def j(self):
480-
for i in xrange(10000):
480+
for i in range(10000):
481481
self.df3[0]
482482

483483

@@ -607,11 +607,11 @@ def g(self):
607607
pass
608608

609609
def h(self):
610-
for i in xrange(10000):
610+
for i in range(10000):
611611
self.df2['A']
612612

613613
def j(self):
614-
for i in xrange(10000):
614+
for i in range(10000):
615615
self.df3[0]
616616

617617

@@ -637,11 +637,11 @@ def g(self):
637637
pass
638638

639639
def h(self):
640-
for i in xrange(10000):
640+
for i in range(10000):
641641
self.df2['A']
642642

643643
def j(self):
644-
for i in xrange(10000):
644+
for i in range(10000):
645645
self.df3[0]
646646

647647

asv_bench/benchmarks/gil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pandas_vb_common import *
1+
from .pandas_vb_common import *
22
from pandas.core import common as com
33
try:
44
from pandas.util.testing import test_parallel

asv_bench/benchmarks/groupby.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from pandas_vb_common import *
2-
from itertools import product
1+
from .pandas_vb_common import *
32
from string import ascii_letters, digits
3+
from itertools import product
44

55

66
class groupby_agg_builtins1(object):
@@ -1535,12 +1535,12 @@ def setup(self):
15351535
self.secid_max = int('F0000000', 16)
15361536
self.step = ((self.secid_max - self.secid_min) // (self.n_securities - 1))
15371537
self.security_ids = map((lambda x: hex(x)[2:10].upper()), range(self.secid_min, (self.secid_max + 1), self.step))
1538-
self.data_index = MultiIndex(levels=[self.dates.values, self.security_ids], labels=[[i for i in xrange(self.n_dates) for _ in xrange(self.n_securities)], (range(self.n_securities) * self.n_dates)], names=['date', 'security_id'])
1538+
self.data_index = MultiIndex(levels=[self.dates.values, self.security_ids], labels=[[i for i in range(self.n_dates) for _ in xrange(self.n_securities)], (range(self.n_securities) * self.n_dates)], names=['date', 'security_id'])
15391539
self.n_data = len(self.data_index)
1540-
self.columns = Index(['factor{}'.format(i) for i in xrange(1, (self.n_columns + 1))])
1540+
self.columns = Index(['factor{}'.format(i) for i in range(1, (self.n_columns + 1))])
15411541
self.data = DataFrame(np.random.randn(self.n_data, self.n_columns), index=self.data_index, columns=self.columns)
15421542
self.step = int((self.n_data * self.share_na))
1543-
for column_index in xrange(self.n_columns):
1543+
for column_index in range(self.n_columns):
15441544
self.index = column_index
15451545
while (self.index < self.n_data):
15461546
self.data.set_value(self.data_index[self.index], self.columns[column_index], np.nan)
@@ -1644,12 +1644,12 @@ def setup(self):
16441644
self.secid_max = int('F0000000', 16)
16451645
self.step = ((self.secid_max - self.secid_min) // (self.n_securities - 1))
16461646
self.security_ids = map((lambda x: hex(x)[2:10].upper()), range(self.secid_min, (self.secid_max + 1), self.step))
1647-
self.data_index = MultiIndex(levels=[self.dates.values, self.security_ids], labels=[[i for i in xrange(self.n_dates) for _ in xrange(self.n_securities)], (range(self.n_securities) * self.n_dates)], names=['date', 'security_id'])
1647+
self.data_index = MultiIndex(levels=[self.dates.values, self.security_ids], labels=[[i for i in range(self.n_dates) for _ in xrange(self.n_securities)], (range(self.n_securities) * self.n_dates)], names=['date', 'security_id'])
16481648
self.n_data = len(self.data_index)
1649-
self.columns = Index(['factor{}'.format(i) for i in xrange(1, (self.n_columns + 1))])
1649+
self.columns = Index(['factor{}'.format(i) for i in range(1, (self.n_columns + 1))])
16501650
self.data = DataFrame(np.random.randn(self.n_data, self.n_columns), index=self.data_index, columns=self.columns)
16511651
self.step = int((self.n_data * self.share_na))
1652-
for column_index in xrange(self.n_columns):
1652+
for column_index in range(self.n_columns):
16531653
self.index = column_index
16541654
while (self.index < self.n_data):
16551655
self.data.set_value(self.data_index[self.index], self.columns[column_index], np.nan)

0 commit comments

Comments
 (0)