Skip to content

A4: Investigate _unstack_once bottleneck #3

Description

@FBumann

Investigation, not yet a proposed fix

Profile of `da.stack().unstack()` on a 200×200×20 dataset shows:

```
48.09% 854 _unstack_once xarray/core/variable.py
12.61% 224 remove_unused_levels pandas/core/indexes/multi.py
3.89% 69 _engine pandas/core/indexes/multi.py
```

Nearly half the wall time is inside xarray's own `_unstack_once`. Need to read the code to determine:

  • Is this fundamental numpy reshape cost (then we're done, can't optimize)?
  • Is it allocation overhead from intermediate arrays?
  • Is it Python-level index manipulation that could be vectorized?

Acceptance

Either: a proposed concrete fix with measured speedup, or a documented conclusion that this is irreducible.


[This is Claude Code on behalf of Felix Bumann]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions