-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
displayio: make Group use a python list internally #4233
Conversation
Looking further into the inheritance mechanisms, it seems that more than one base class for a subclass is not supported: https://github.com/adafruit/circuitpython/blob/main/py/objtype.c#L108 That means that |
I can't make the |
Note that it would be possible to add just the sort method without using a list internally — that function can sort any continuous array of python objects. |
d23a7ed
to
fa1b6af
Compare
@deshipu Is this ready for review? Could you update the title to match your implementation? Thanks! |
df5989d
to
5b503ab
Compare
Sorry, I missed the title is wrong. I rebased on top of main now, and removed the unnecessary changes. It's ready for reviews, thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this!
I think you should add a deprecation notice in the docs of max_size (yay!!!) to say it'll be removed in 7.x and make it do nothing internally.
Thank you for your review, I will work on this further over the weekend. |
Since we want to expose the list of group's children to the user, we should only have the original objects in it, without any other additional data, and compute the native object as needed.
This is a first go at it, done by naive replacing of all array operations with corresponding operations on the list. Note that there is a lot of unnecessary type conversions, here. Also, list_pop has been copied, because it's decalerd STATIC in py/objlist.h
Still accept it as an argument. Add deprecation note.
5a49467
to
38fb7b5
Compare
Note that for some reason this makes the binary 500 bytes larger!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me! Thank you! ugame10
looks unhappy though unfortunately.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thank you!
The
displayio.Group
should use a python list for keeping its members, so that we don't have to setmax_size
explicitly, and we can use list-like methods likesort
on it.