Skip to content

Commit

Permalink
Speed up Vector init from list
Browse files Browse the repository at this point in the history
  • Loading branch information
otsaloma committed Dec 10, 2024
1 parent a8a7a84 commit abbeefe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
select = E1,E9,F
ignore = E129
ignore = E125,E129
exclude = doc/comparison/blocks,venv
4 changes: 3 additions & 1 deletion dataiter/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ def _np_array(cls, object, dtype=None):
# NumPy still defaults to fixed width strings.
# In some cases we can only fix the dtype ex-post.
if dtype is None:
if util.unique_types(object) == {str}:
if object and (
isinstance(object[0], str) and
isinstance(object[-1], str)):
dtype = dtypes.string
dtype = cls._map_input_dtype(dtype)
array = np.array(object, dtype)
Expand Down

0 comments on commit abbeefe

Please sign in to comment.