Skip to content
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

First attempt to port the repo from python2 to python3 with 2to3 #79

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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 grumpy-runtime-src/benchmarks/bm_call_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def qux(self):

def BenchmarkCallMethod(b):
f = Foo()
for _ in xrange(b.N):
for _ in range(b.N):
# 20 calls
f.foo(1, 2, 3, 4)
f.foo(1, 2, 3, 4)
Expand Down
2 changes: 1 addition & 1 deletion grumpy-runtime-src/benchmarks/bm_call_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def qux():


def BenchmarkCallSimple(b):
for _ in xrange(b.N):
for _ in range(b.N):
# 20 calls
foo(1, 2, 3, 4)
foo(1, 2, 3, 4)
Expand Down
12 changes: 6 additions & 6 deletions grumpy-runtime-src/benchmarks/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,42 @@
def BenchmarkCallNoArgs(b):
def Foo():
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo()


def BenchmarkCallPositionalArgs(b):
def Foo(a, b, c):
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo(1, 2, 3)


def BenchmarkCallKeywords(b):
def Foo(a, b, c):
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo(a=1, b=2, c=3)


def BenchmarkCallDefaults(b):
def Foo(a=1, b=2, c=3):
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo()


def BenchmarkCallVarArgs(b):
def Foo(*args):
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo(1, 2, 3)


def BenchmarkCallKwargs(b):
def Foo(**kwargs):
pass
for _ in xrange(b.N):
for _ in range(b.N):
Foo(a=1, b=2, c=3)


Expand Down
12 changes: 6 additions & 6 deletions grumpy-runtime-src/benchmarks/comprehension.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@

def BenchmarkGeneratorExpCreate(b):
l = []
for _ in xrange(b.N):
for _ in range(b.N):
(x for x in l) # pylint: disable=pointless-statement


def BenchmarkGeneratorExpIterate(b):
for _ in (x for x in xrange(b.N)):
for _ in (x for x in range(b.N)):
pass


def BenchmarkListCompCreate(b):
for _ in xrange(b.N):
[x for x in xrange(1000)] # pylint: disable=expression-not-assigned
for _ in range(b.N):
[x for x in range(1000)] # pylint: disable=expression-not-assigned


def BenchmarkDictCompCreate(b):
for _ in xrange(b.N):
{x: x for x in xrange(1000)} # pylint: disable=expression-not-assigned
for _ in range(b.N):
{x: x for x in list(range(1000))} # pylint: disable=expression-not-assigned


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions grumpy-runtime-src/benchmarks/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def Benchmark(b): # pylint: disable=missing-docstring
e = threading.Event()
def Target():
e.wait()
for _ in xrange(b.N / p):
for _ in range(b.N / p):
work_func(*args)
threads = []
for _ in xrange(p):
for _ in range(p):
t = threading.Thread(target=Target)
t.start()
threads.append(t)
Expand All @@ -56,7 +56,7 @@ def Target():


def _RegisterBenchmarks():
for p in xrange(1, 13):
for p in range(1, 13):
for work_func, arg in _WORKLOADS:
name = 'Benchmark' + work_func.__name__
if p > 1:
Expand Down
14 changes: 7 additions & 7 deletions grumpy-runtime-src/benchmarks/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,43 @@


def BenchmarkDictCreate(b):
for _ in xrange(b.N):
for _ in range(b.N):
d = {'one': 1, 'two': 2, 'three': 3}


def BenchmarkDictCreateFunc(b):
for _ in xrange(b.N):
for _ in range(b.N):
d = dict(one=1, two=2, three=3)


def BenchmarkDictGetItem(b):
d = {42: 123}
for _ in xrange(b.N):
for _ in range(b.N):
d[42]


def BenchmarkDictStringOnlyGetItem(b):
d = {'foo': 123}
for _ in xrange(b.N):
for _ in range(b.N):
d['foo']


def BenchmarkDictSetItem(b):
d = {}
for _ in xrange(b.N):
for _ in range(b.N):
d[42] = 123


def BenchmarkDictStringOnlySetItem(b):
d = {}
for _ in xrange(b.N):
for _ in range(b.N):
d['foo'] = 123


def BenchmarkHashStrCached(b):
"""Hashes the same value repeatedly to exercise any hash caching logic."""
h = hash # Prevent builtins lookup each iteration.
for _ in xrange(b.N):
for _ in range(b.N):
h('foobarfoobarfoobar')


Expand Down
4 changes: 2 additions & 2 deletions grumpy-runtime-src/benchmarks/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def BenchmarkGeneratorIterate(b):
def Gen(n):
for i in xrange(n):
for i in range(n):
yield i
for _ in Gen(b.N):
pass
Expand All @@ -28,7 +28,7 @@ def Gen(n):
def BenchmarkGeneratorCreate(b):
def Gen():
yield 1
for _ in xrange(b.N):
for _ in range(b.N):
Gen()


Expand Down
8 changes: 4 additions & 4 deletions grumpy-runtime-src/benchmarks/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

def BenchmarkListGetItem(b):
l = [1, 3, 9]
for _ in xrange(b.N):
for _ in range(b.N):
l[2]


def BenchmarkListContains3(b):
l = [1, 3, 9]
for _ in xrange(b.N):
for _ in range(b.N):
9 in l


def BenchmarkListContains10(b):
l = range(10)
for _ in xrange(b.N):
l = list(range(10))
for _ in range(b.N):
9 in l


Expand Down
6 changes: 3 additions & 3 deletions grumpy-runtime-src/benchmarks/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def BenchmarkForXRange(b):
for _ in xrange(b.N):
for _ in range(b.N):
pass


Expand All @@ -29,10 +29,10 @@ def BenchmarkWhileCounter(b):


def BenchmarkWhileXRange(b):
i = iter(xrange(b.N))
i = iter(list(range(b.N)))
try:
while True:
i.next()
next(i)
except StopIteration:
pass

Expand Down
6 changes: 3 additions & 3 deletions grumpy-runtime-src/benchmarks/tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

def BenchmarkTupleGetItem(b):
l = (1, 3, 9)
for _ in xrange(b.N):
for _ in range(b.N):
l[2]


def BenchmarkTupleContains3(b):
t = (1, 3, 9)
for _ in xrange(b.N):
for _ in range(b.N):
9 in t


def BenchmarkTupleContains10(b):
t = tuple(range(10))
for _ in xrange(b.N):
for _ in range(b.N):
9 in t


Expand Down
1 change: 0 additions & 1 deletion grumpy-runtime-src/lib/cStringIO.py

This file was deleted.

Loading