Reduce key dictionary memory footprint
Instead of indexing `Key` objects that have multiple names by each individual name, index by the set of names. This reduces the size of the default key dictionary by a factor of between 2 and 3, and as result also reduces reallocations/defragmentation. Instead of instantiating all module/extension keys by default, append them to the `maybe_key`-generator list.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from kmk.keys import make_argumented_key
|
||||
from kmk.keys import KC, maybe_make_argumented_key
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ class StickyMod(Module):
|
||||
def __init__(self):
|
||||
self._active = False
|
||||
self._active_key = None
|
||||
make_argumented_key(
|
||||
names=('SM',),
|
||||
validator=StickyModMeta,
|
||||
on_press=self.sm_pressed,
|
||||
on_release=self.sm_released,
|
||||
KC._generators.append(
|
||||
maybe_make_argumented_key(
|
||||
names=('SM',),
|
||||
validator=StickyModMeta,
|
||||
on_press=self.sm_pressed,
|
||||
on_release=self.sm_released,
|
||||
)
|
||||
)
|
||||
|
||||
def during_bootup(self, keyboard):
|
||||
|
Reference in New Issue
Block a user