Skip to content

Commit c9e9a37

Browse files
chore: switch to functools.cached_property for intensive code
1 parent d119620 commit c9e9a37

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

discord/onboarding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from __future__ import annotations
2626

2727
from typing import TYPE_CHECKING, Any
28+
from functools import cached_property
2829

2930
from .enums import OnboardingMode, PromptType, try_enum
3031
from .partial_emoji import PartialEmoji
@@ -247,7 +248,7 @@ def _update(self, data: OnboardingPayload):
247248
self.enabled: bool = data["enabled"]
248249
self.mode: OnboardingMode = try_enum(OnboardingMode, data.get("mode"))
249250

250-
@property
251+
@cached_property
251252
def default_channels(
252253
self,
253254
) -> list[TextChannel | ForumChannel | VoiceChannel | Object]:

discord/poll.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import datetime
2828
from typing import TYPE_CHECKING, Any
29+
from functools import cached_property
2930

3031
from . import utils
3132
from .enums import PollLayoutType, try_enum
@@ -358,7 +359,7 @@ def __init__(
358359
self._expiry = None
359360
self._message = None
360361

361-
@property
362+
@cached_property
362363
def expiry(self) -> datetime.datetime | None:
363364
"""An aware datetime object that specifies the date and time in UTC when the poll will end."""
364365
return utils.parse_time(self._expiry)

0 commit comments

Comments
 (0)