mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-07 10:22:59 +00:00
Change certain sequences to use a special proxy type instead of list
This is to speed up cases where someone is just querying the length of the underlying sequence. If anything else is done to the sequence then it is copied from the original iterator. This change should be mostly transparent.
This commit is contained in:
@ -378,8 +378,8 @@ class ConnectionState:
|
||||
return self._view_store.persistent_views
|
||||
|
||||
@property
|
||||
def guilds(self) -> List[Guild]:
|
||||
return list(self._guilds.values())
|
||||
def guilds(self) -> Sequence[Guild]:
|
||||
return utils.SequenceProxy(self._guilds.values())
|
||||
|
||||
def _get_guild(self, guild_id: Optional[int]) -> Optional[Guild]:
|
||||
# the keys of self._guilds are ints
|
||||
@ -403,12 +403,12 @@ class ConnectionState:
|
||||
del guild
|
||||
|
||||
@property
|
||||
def emojis(self) -> List[Emoji]:
|
||||
return list(self._emojis.values())
|
||||
def emojis(self) -> Sequence[Emoji]:
|
||||
return utils.SequenceProxy(self._emojis.values())
|
||||
|
||||
@property
|
||||
def stickers(self) -> List[GuildSticker]:
|
||||
return list(self._stickers.values())
|
||||
def stickers(self) -> Sequence[GuildSticker]:
|
||||
return utils.SequenceProxy(self._stickers.values())
|
||||
|
||||
def get_emoji(self, emoji_id: Optional[int]) -> Optional[Emoji]:
|
||||
# the keys of self._emojis are ints
|
||||
@ -419,8 +419,8 @@ class ConnectionState:
|
||||
return self._stickers.get(sticker_id) # type: ignore
|
||||
|
||||
@property
|
||||
def private_channels(self) -> List[PrivateChannel]:
|
||||
return list(self._private_channels.values())
|
||||
def private_channels(self) -> Sequence[PrivateChannel]:
|
||||
return utils.SequenceProxy(self._private_channels.values())
|
||||
|
||||
def _get_private_channel(self, channel_id: Optional[int]) -> Optional[PrivateChannel]:
|
||||
try:
|
||||
|
Reference in New Issue
Block a user