arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Making SpriteList a Generic

Open Hunter2809 opened this issue 3 years ago • 3 comments

As of now, we cannot manually typehint SpriteList, so it is always the type of SpriteList[Sprite]. Making it a generic would enable a dev to add a custom typehint to the same variable, something like SpriteList[MyCustomSprite], knowing the SpriteList is gonna contain only those sprite instances.

Hunter2809 avatar Jun 16 '22 11:06 Hunter2809

Do we want to go beyond just generics to make SpriteList implement the full MutableSequence ABC? I'm not sure what the performance implications of that are in current Python versions.

pushfoo avatar Aug 02 '22 05:08 pushfoo

That seems like a good idea.

Hunter2809 avatar Aug 02 '22 08:08 Hunter2809

What other options do we have here? I haven't really looked into typying with lists.

einarf avatar Aug 02 '22 13:08 einarf

This may have already been addressed in #1399 by @eruvanos: https://github.com/pythonarcade/arcade/blob/0e765e3d97d408667ed67bb158860b82f97101db/arcade/sprite_list/sprite_list.py#L53

Making SpriteList into a full MutableSequence is still worth considering but not urgent.

pushfoo avatar Feb 17 '23 21:02 pushfoo

Done.

einarf avatar Feb 20 '23 04:02 einarf