summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorDaniel Hrisca <daniel.hrisca@gmail.com>2019-01-13 10:07:53 +0200
committerMatti Picus <matti.picus@gmail.com>2019-01-13 10:07:53 +0200
commite39a847518acd49e6ac19493f793feefcc2d63ac (patch)
tree8ee35246d5f06b042fdd433812c6cb15097e7c83 /numpy
parent5af524421dd14107cbf05db942f0cc3f5a7656e7 (diff)
downloadnumpy-e39a847518acd49e6ac19493f793feefcc2d63ac.tar.gz
ENH: improve performance of numpy.core.records.fromarrays (#12596)
* ENH: improve performance of numpy.core.records.fromarrays and add benchmarks
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/records.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 4d18c5712..4ea83accc 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -167,10 +167,12 @@ class format_parser(object):
if formats is None:
raise ValueError("Need formats argument")
if isinstance(formats, list):
- if len(formats) < 2:
- formats.append('')
- formats = ','.join(formats)
- dtype = sb.dtype(formats, aligned)
+ dtype = sb.dtype(
+ [('f{}'.format(i), format_) for i, format_ in enumerate(formats)],
+ aligned,
+ )
+ else:
+ dtype = sb.dtype(formats, aligned)
fields = dtype.fields
if fields is None:
dtype = sb.dtype([('f1', dtype)], aligned)
@@ -611,7 +613,6 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
if not isinstance(obj, ndarray):
raise ValueError("item in the array list must be an ndarray.")
formats.append(obj.dtype.str)
- formats = ','.join(formats)
if dtype is not None:
descr = sb.dtype(dtype)