diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-02 11:59:47 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-02 11:59:47 +0200 |
commit | c4dbc4d63b796407634a48e42ae58d63f299f66b (patch) | |
tree | 218690742687b63296bbca54ebfd5b5e2c48d262 | |
parent | ac1d79a656863c1693b0419586b3540702bbf795 (diff) | |
download | cython-c4dbc4d63b796407634a48e42ae58d63f299f66b.tar.gz |
Avoid unnecessary int-object creation when formatting numbers as strings in format_from_typeinfo() utility function.
-rw-r--r-- | Cython/Utility/MemoryView.pyx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Cython/Utility/MemoryView.pyx b/Cython/Utility/MemoryView.pyx index 5d856fdb9..1e4e40e75 100644 --- a/Cython/Utility/MemoryView.pyx +++ b/Cython/Utility/MemoryView.pyx @@ -1455,6 +1455,7 @@ cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type): cdef __Pyx_StructField *field cdef __pyx_typeinfo_string fmt cdef bytes part, result + cdef Py_ssize_t i if type.typegroup == 'S': assert type.fields != NULL and type.fields.type != NULL @@ -1475,10 +1476,9 @@ cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type): result = alignment.join(parts) + b'}' else: fmt = __Pyx_TypeInfoToFormat(type) + result = fmt.string if type.arraysize[0]: - extents = [unicode(type.arraysize[i]) for i in range(type.ndim)] - result = f"({u','.join(extents)})".encode('ascii') + fmt.string - else: - result = fmt.string + extents = [f"{type.arraysize[i]}" for i in range(type.ndim)] + result = f"({u','.join(extents)})".encode('ascii') + result return result |