Skip to content

CLN: collect fastpath in Series.__init__ #49575

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 2 commits into from
Nov 9, 2022

Conversation

topper-123
Copy link
Contributor

Collect fastpath functionality in one place simplifies implementation

# skips validation of the name
object.__setattr__(self, "_name", name)
NDFrame.__init__(self, data)
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fastpath now ends here and everything below can simply be moved one level to the left.

@topper-123
Copy link
Contributor Author

The failed check seems unrelated.

@mroeschke mroeschke added Clean Constructors Series/DataFrame/Index/pd.array Constructors labels Nov 8, 2022
@@ -378,103 +377,99 @@ def __init__(
data = SingleArrayManager.from_array(data, index)
if copy:
data = data.copy()
if index is None:
Copy link
Member

Choose a reason for hiding this comment

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

Why is this if index is None: check no longer needed in the fastpath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you follow the code all the way down to the end of the method you can see that this actually is a noop; It's superflous code and can be removed. It was just difficult to see in the old code.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay I see it now. Thanks

@mroeschke mroeschke added the Series Series data structure label Nov 8, 2022
@mroeschke mroeschke modified the milestones: No action, 2.0 Nov 9, 2022
@mroeschke mroeschke merged commit b8bcf50 into pandas-dev:main Nov 9, 2022
@mroeschke
Copy link
Member

Thanks @topper-123

phofl pushed a commit to phofl/pandas that referenced this pull request Nov 9, 2022
* CLN: collect fastpath in Series.__init__

* small clean

Co-authored-by: Terji Petersen <[email protected]>
@topper-123 topper-123 deleted the simplify_series__init__ branch November 9, 2022 18:18
codamuse pushed a commit to codamuse/pandas that referenced this pull request Nov 12, 2022
* CLN: collect fastpath in Series.__init__

* small clean

Co-authored-by: Terji Petersen <[email protected]>
mliu08 pushed a commit to mliu08/pandas that referenced this pull request Nov 27, 2022
* CLN: collect fastpath in Series.__init__

* small clean

Co-authored-by: Terji Petersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Constructors Series/DataFrame/Index/pd.array Constructors Series Series data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants