Skip to content

Commit 45a1dcf

Browse files
author
James William Pye
committed
Use nonlocal for size.
1 parent 2663265 commit 45a1dcf

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

postgresql/test/perf_copy_io.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ def testSpeed(tuples = 50000 * 3):
2323
"(i int, t text, mt text, ts text, ty text, tx text);")
2424
try:
2525
Q = prepare("COPY _copy FROM STDIN")
26-
size = [0]
26+
size = 0
2727
def incsize(data):
2828
'count of bytes'
29-
size[0] += len(data)
29+
nonlocal size
30+
size += len(data)
3031
return data
3132
sys.stderr.write("preparing data(%d tuples)...\n" %(tuples,))
3233

@@ -48,9 +49,9 @@ def incsize(data):
4849
"average tuple size(bytes): %f\n " \
4950
"average KB per second: %f\n " \
5051
"average tuples per second: %f\n" %(
51-
tuples, size[0], duration,
52-
size[0] / tuples,
53-
size[0] / 1024 / duration,
52+
tuples, size, duration,
53+
size / tuples,
54+
size / 1024 / duration,
5455
tuples / duration,
5556
)
5657
)
@@ -67,7 +68,7 @@ def incsize(data):
6768
"average KB per second: %f\n " \
6869
"average tuples per second: %f\n " %(
6970
c, duration,
70-
size[0] / 1024 / duration,
71+
size / 1024 / duration,
7172
tuples / duration,
7273
)
7374
)

0 commit comments

Comments
 (0)