Skip to content

Conversation

jorisvandenbossche
Copy link
Member

@jbrockmendel #42797 added an unconditional copy, while if you reindex the arrays, you already are sure you have a copy.

This gives a 20% improvement on some of the merge benchmarks.

@jorisvandenbossche jorisvandenbossche added ArrayManager Performance Memory or execution speed performance labels Nov 21, 2021
@jorisvandenbossche jorisvandenbossche added this to the 1.4 milestone Nov 21, 2021
assert concat_axis == 0
arrays = list(itertools.chain.from_iterable([mgr.arrays for mgr in mgrs]))
if copy:
if copy and axis1_needs_copy_this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be cleaner (and avoid copies in corner cases) to do this up in the for loop right before mgrs.append(mgr)

Copy link
Member Author

@jorisvandenbossche jorisvandenbossche Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea, and that also simplified it quite a bit

@jreback
Copy link
Contributor

jreback commented Nov 28, 2021

lgtm @jbrockmendel comment could be addressed here

# reindex all arrays
mgrs = []
for mgr, indexers in mgrs_indexers:
axis1_needs_copy = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick again: elsewhere in this file we do basically the same thing with made_copy = False

@jreback jreback merged commit 4b71090 into pandas-dev:master Dec 6, 2021
@jorisvandenbossche jorisvandenbossche deleted the am-perf-concat-mgrs-avoid-copy branch December 6, 2021 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Memory or execution speed performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants