Skip to content

Add more __slots__ #1764

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 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions arcade/gui/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class _Obs(Generic[P]):
Internal holder for Property value and change listeners
"""

__slots__ = "value", "listeners"
__slots__ = ("value", "listeners")

def __init__(self, value: P):
self.value = value
Expand All @@ -26,7 +26,7 @@ class Property(Generic[P]):
:param default_factory: A callable which returns the default value.
Will be called with the property and the instance
"""
__slots__ = "name", "default_factory", "obs"
__slots__ = ("name", "default_factory", "obs")
name: str

def __init__(self, default: Optional[P] = None, default_factory: Optional[Callable[[Any, Any], P]] = None):
Expand Down Expand Up @@ -112,7 +112,13 @@ class MyObject:


class _ObservableDict(dict):
# Internal class to observe changes inside a native python dict.
"""Internal class to observe changes inside a native python dict."""

__slots__ = (
"prop",
"obj"
)

def __init__(self, prop: Property, instance, *largs):
self.prop: Property = prop
self.obj = ref(instance)
Expand Down Expand Up @@ -167,7 +173,13 @@ def set(self, instance, value: dict):


class _ObservableList(list):
# Internal class to observe changes inside a native python list.
"""Internal class to observe changes inside a native python list."""

__slots__ = (
"prop",
"obj"
)

def __init__(self, prop: Property, instance, *largs):
self.prop: Property = prop
self.obj = ref(instance)
Expand Down
1 change: 0 additions & 1 deletion arcade/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class _AStarGraph(object):
:param int bottom: Far bottom side y value
:param int top: Far top side y value
"""

def __init__(self, barriers: Union[List, Tuple, Set],
left: int,
right: int,
Expand Down