summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-06-29 03:37:04 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-06-29 03:37:04 +0000
commitb6bbec80f381af3e6bee64cbbcfbdf92ad71c4ec (patch)
treee98bade00a115b070606c2d38fddb61bb8021db2
parent92ce54ed154e972e649800fcfceda52458c18664 (diff)
downloadnumpy-b6bbec80f381af3e6bee64cbbcfbdf92ad71c4ec.tar.gz
Use join instead of += to build string.
-rw-r--r--numpy/lib/format.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 13e96f303..c1c7740bb 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -168,11 +168,12 @@ def write_array_header_1_0(fp, d):
This has the appropriate entries for writing its string representation
to the header of the file.
"""
- header = "{"
+ header = ["{"]
for key, value in sorted(d.items()):
# Need to use repr here, since we eval these when reading
- header += "'%s': %s, " % (key, repr(value))
- header += "}"
+ header.append("'%s': %s, " % (key, repr(value)))
+ header.append("}")
+ header = "".join(header)
# Pad the header with spaces and a final newline such that the magic
# string, the header-length short and the header are aligned on a 16-byte
# boundary. Hopefully, some system, possibly memory-mapping, can take