File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change 88Also this makes the module light to import, as it should.
99"""
1010from enum import Enum
11- from functools import lru_cache
1211from typing import Optional
1312from typing import TYPE_CHECKING
1413
@@ -29,7 +28,7 @@ class Scope(Enum):
2928
3029 def index (self ) -> int :
3130 """Return this scope index. Smaller numbers indicate higher scopes (Session = 0)."""
32- return _scope_to_index ( self )
31+ return _SCOPE_INDICES [ self ]
3332
3433 def next (self ) -> "Scope" :
3534 """Return the next scope (from top to bottom)."""
@@ -70,9 +69,5 @@ def from_user(
7069 Scope .Class : Scope .Function ,
7170}
7271
73-
74- @lru_cache (maxsize = None )
75- def _scope_to_index (scope : Scope ) -> int :
76- """Implementation of Scope.index() as a free function so we can cache it."""
77- scopes = list (Scope )
78- return scopes .index (scope )
72+ # Maps a scope to its internal index, with Session = 0, Package = 1, and so on.
73+ _SCOPE_INDICES = {s : i for i , s in enumerate (Scope )}
You can’t perform that action at this time.
0 commit comments