Skip to content

Commit 565c9a3

Browse files
burnpanckshoyer
authored andcommitted
Fix slow object arrays indexing (#1122)
* fixing #1121 * added changelog
1 parent 0c5fa1e commit 565c9a3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ Bug fixes
134134
(:issue:`1116`).
135135
By `Yves Delley <https://github.com/burnpanck>`_.
136136

137+
- Fixed sub-optimal performance in certain operations with object arrays (:issue:`1121`).
138+
By `Yves Delley <https://github.com/burnpanck>`_.
139+
137140
.. _whats-new.0.8.2:
138141

139142
v0.8.2 (18 August 2016)

xarray/core/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ def is_valid_numpy_dtype(dtype):
197197

198198
def to_0d_object_array(value):
199199
"""Given a value, wrap it in a 0-D numpy.ndarray with dtype=object."""
200-
result = np.empty((1,), dtype=object)
201-
result[:] = [value]
202-
result.shape = ()
200+
result = np.empty((), dtype=object)
201+
result[()] = value
203202
return result
204203

205204

0 commit comments

Comments
 (0)