Skip to content

REF: SingleBlockManager dont subclass BlockManager #40625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 8, 2021

Conversation

jbrockmendel
Copy link
Member

Instead, most of BlockManager becomes _BlockManager which is subclassed by SingleBlockManager and BlockManager, the latter holding only the 2d-specific BM methods.

Motivation: putting BlockManager constructor in cython gives a much bigger gain if we can define __cinit__, and we can't do that with the two subclasses having mismatched __init__ signatures.

@jbrockmendel jbrockmendel added Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code labels Mar 26, 2021
@jbrockmendel
Copy link
Member Author

@jreback gentle ping, this is preliminary to some nice perf (constructor) improvements (along with #40776, #40757)

@jreback jreback added this to the 1.3 milestone Apr 8, 2021


class BlockManager(DataManager):
class _BlockManager(DataManager):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you indicate that this is an abstract class (alt put ABC in the name)

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea

Copy link
Member Author

Choose a reason for hiding this comment

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

updated + green

@@ -1474,21 +1387,123 @@ def take(self: T, indexer, axis: int = 1, verify: bool = True) -> T:
consolidate=False,
)

def _equal_values(self: T, other: T) -> bool:

class BlockManager(_BlockManager):
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we actually name it Block2DManager then

Copy link
Member Author

Choose a reason for hiding this comment

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

bc (to my chagrin) downstream packages access it

Copy link
Contributor

Choose a reason for hiding this comment

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

WAT, gawd. ok

# Populate known_consolidate, blknos, and blklocs lazily
self._known_consolidated = False
# error: Incompatible types in assignment (expression has type "None",
# variable has type "ndarray")
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need all these?

Copy link
Member Author

Choose a reason for hiding this comment

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

the attributes or the "type ignore"s?

Copy link
Contributor

Choose a reason for hiding this comment

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

the type ignores, but certainly can be in a followup

self._blklocs = None # type: ignore[assignment]

@classmethod
def _simple_new(cls, blocks: tuple[Block, ...], axes: list[Index]):
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't you have an abc for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

nothing in the base class uses _simple_new, so no

Copy link
Contributor

Choose a reason for hiding this comment

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

i guess that is the question, why is that?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

couple of comments, but certailnly can be in followups

@jreback jreback merged commit 1f7dd7f into pandas-dev:master Apr 8, 2021
@jbrockmendel jbrockmendel deleted the ref-bm2d branch April 8, 2021 20:57
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants