Add __slots__ to data enumerations

These types still have a __dict__, since they inherit from Enum, but
using __slots__ for the inherited properties can still improve access
times.
This commit is contained in:
Jeremy Saklad 2021-09-18 18:24:54 -05:00
parent 50625cdc27
commit 97aedc0895
Signed by: Jeremy Saklad
GPG Key ID: 9CA2149583EDBF84
11 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Adjustment(Enum): class Adjustment(Enum):
"""An action that is taken after all parts have been added to a skeleton.""" """An action that is taken after all parts have been added to a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
CARVE_AWAY_AGE = Action( CARVE_AWAY_AGE = Action(
"Carve away some evidence of age", "Carve away some evidence of age",
cost = Cost.ACTION.value, cost = Cost.ACTION.value,

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Appendage(Enum): class Appendage(Enum):
"""An action that is taken once all skulls are added to a skeleton.""" """An action that is taken once all skulls are added to a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
# Cost from this scales with limbs and is partially implemented separately # Cost from this scales with limbs and is partially implemented separately
ADD_JOINTS = Action( ADD_JOINTS = Action(
"Add four more joints to your skeleton", "Add four more joints to your skeleton",

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Buyer(Enum): class Buyer(Enum):
"""An action that converts a skeleton into revenue.""" """An action that converts a skeleton into revenue."""
__slots__ = '_value_', '_name_', '__objclass__'
A_PALAEONTOLOGIST_WITH_HOARDING_PROPENSITIES = Action( A_PALAEONTOLOGIST_WITH_HOARDING_PROPENSITIES = Action(
"Sell a complete skeleton to the Bone Hoarder", "Sell a complete skeleton to the Bone Hoarder",
cost = Cost.ACTION.value cost = Cost.ACTION.value

View File

@ -8,6 +8,8 @@ from ortools.sat.python import cp_model
class Cost(Enum): class Cost(Enum):
"""The number of pennies needed to produce a quality.""" """The number of pennies needed to produce a quality."""
__slots__ = '_value_', '_name_', '__objclass__'
# This is your baseline EPA: the pennies you could generate using an action for a generic grind. # This is your baseline EPA: the pennies you could generate using an action for a generic grind.
ACTION = 400 ACTION = 400

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Declaration(Enum): class Declaration(Enum):
"""An action that is taken after all adjustments have been made to a skeleton.""" """An action that is taken after all adjustments have been made to a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
AMPHIBIAN = Action( AMPHIBIAN = Action(
"Declare your (Skeleton Type) a completed Amphibian", "Declare your (Skeleton Type) a completed Amphibian",
cost = Cost.ACTION.value cost = Cost.ACTION.value

View File

@ -12,3 +12,4 @@ DiplomatFascination = Enum(
module = __name__ module = __name__
) )
DiplomatFascination.__doc__ = "The current fascination of the Trifling Diplomat." DiplomatFascination.__doc__ = "The current fascination of the Trifling Diplomat."
DiplomatFascination.__slots__ = '_value_', '_name_', '__objclass__'

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Embellishment(Enum): class Embellishment(Enum):
"""An action is taken after a declaration has been made for a skeleton.""" """An action is taken after a declaration has been made for a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
MORE_PLAUSIBLE = Action( MORE_PLAUSIBLE = Action(
"Make it seem just a bit more plausible", "Make it seem just a bit more plausible",
cost = Cost.ACTION.value + Cost.REVISIONIST_NARRATIVE.value, cost = Cost.ACTION.value + Cost.REVISIONIST_NARRATIVE.value,

View File

@ -6,6 +6,8 @@ from enum import Enum
class Fluctuation(Enum): class Fluctuation(Enum):
"""Which skeleton attribute is currently boosted.""" """Which skeleton attribute is currently boosted."""
__slots__ = '_value_', '_name_', '__objclass__'
ANTIQUITY = 1 ANTIQUITY = 1
AMALGAMY = 2 AMALGAMY = 2
MENACE = 3 MENACE = 3

View File

@ -8,6 +8,8 @@ from .buyers import Buyer
class OccasionalBuyer(Enum): class OccasionalBuyer(Enum):
"""Which of several unusual buyers are available.""" """Which of several unusual buyers are available."""
__slots__ = '_value_', '_name_', '__objclass__'
AN_ENTHUSIAST_IN_SKULLS = [Buyer.AN_ENTHUSIAST_IN_SKULLS] AN_ENTHUSIAST_IN_SKULLS = [Buyer.AN_ENTHUSIAST_IN_SKULLS]
A_DREARY_MIDNIGHTER = [Buyer.A_DREARY_MIDNIGHTER] A_DREARY_MIDNIGHTER = [Buyer.A_DREARY_MIDNIGHTER]

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Skull(Enum): class Skull(Enum):
"""An action that is taken immediately after starting a skeleton.""" """An action that is taken immediately after starting a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
BAPTIST_SKULL = Action( BAPTIST_SKULL = Action(
"Duplicate the skull of John the Baptist, if you can call that a skull", "Duplicate the skull of John the Baptist, if you can call that a skull",
cost = Cost.ACTION.value + 500*Cost.BONE_FRAGMENT.value + 10*Cost.PEPPERCAPS.value, cost = Cost.ACTION.value + 500*Cost.BONE_FRAGMENT.value + 10*Cost.PEPPERCAPS.value,

View File

@ -9,6 +9,8 @@ from ..objects.action import Action
class Torso(Enum): class Torso(Enum):
"""An action that initiates a skeleton.""" """An action that initiates a skeleton."""
__slots__ = '_value_', '_name_', '__objclass__'
HEADLESS_HUMANOID = Action( HEADLESS_HUMANOID = Action(
"Reassemble your Headless Humanoid", "Reassemble your Headless Humanoid",
cost = Cost.ACTION.value + Cost.HEADLESS_SKELETON.value, cost = Cost.ACTION.value + Cost.HEADLESS_SKELETON.value,