← 返回首页
Use simpler form of super() where possible by almarklein · Pull Request #453 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Use simpler form of super() where possible#453

Merged
kushalkolar merged 3 commits into
fastplotlib:mainfrom
almarklein:super
Mar 29, 2024
Merged

Use simpler form of super() where possible#453
kushalkolar merged 3 commits into
fastplotlib:mainfrom
almarklein:super

Conversation

almarklein commented Mar 27, 2024
edited
Loading

Copy link
Copy Markdown
Collaborator

These caught my eye in my earlier review. Simple fix that makes the code a bit simplere / easier to read, but possibly also avoids bugs.

Context:

class Foo: def __init__(self): print("init Foo") class Bar(Foo): def __init__(self): super().__init__() print("init Bar") class Spam(Bar): def __init__(self): super().__init__() print("init Spam") Spam()

Produces:

init Foo init Bar init Spam

Replacing the super() in Spam with super(Spam, self).__init__() produces the same result.
But if it is replaced with super(Foo, self).__init__(), it produces:

init Foo init Spam

Comment thread fastplotlib/graphics/_features/_colors.py Show resolved Hide resolved

Copy link
Copy Markdown
Collaborator Author

Also looking into Subplot, which has multiple inheritance.

For reference:

class Foo: def __init__(self): super().__init__() print("init Foo") class Bar(): def __init__(self): super().__init__() print("init Bar") class Spam(Bar, Foo): def __init__(self): super().__init__() print("init Spam") Spam()

Produces:

init Foo init Bar init Spam

Copy link
Copy Markdown
Collaborator Author

There's a lot of multiple inheritance when you get to the plots and graphics, and that results in some juggling with super and direct calls to SomeSuperclass.__init__. Will not burn my hands on that right now. Let's keep this pr small 😅

Comment thread fastplotlib/layouts/_plot.py Show resolved Hide resolved
kushalkolar marked this pull request as ready for review March 28, 2024 02:11
kushalkolar requested a review from clewis7 as a code owner March 28, 2024 02:11
kushalkolar merged commit 0021652 into fastplotlib:main Mar 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.