Avoid listifying left/right operand in ExtensionArray ops dispatching · Issue #22922 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@jorisvandenbossche

Description

@jorisvandenbossche

We now have the follow code in the ExtensionArray ops dispatching:

# TODO(jreback)
# we need to listify to avoid ndarray, or non-same-type extension array
# dispatching
if is_extension_array_dtype(left):
new_left = left.values
if isinstance(right, np.ndarray):
# handle numpy scalars, this is a PITA
# TODO(jreback)
new_right = lib.item_from_zerodim(right)
if is_scalar(new_right):
new_right = [new_right]
new_right = list(new_right)
elif is_extension_array_dtype(right) and type(left) != type(right):
new_right = list(new_right)
else:
new_right = right
else:
new_left = list(left.values)
new_right = right

There are a few places where we convert the values to a list, which should be avoided.