2
2
3
3
import typing
4
4
import enum
5
+ import warnings
5
6
from json import JSONEncoder , JSONDecoder
6
7
7
8
import websockets
@@ -362,7 +363,8 @@ def get_for_player(self, slot: int) -> typing.Dict[int, typing.Set[int]]:
362
363
all_locations [source_slot ].add (location_id )
363
364
return all_locations
364
365
365
- def get_checked (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int ):
366
+ def get_checked (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int
367
+ ) -> typing .List [int ]:
366
368
checked = state [team , slot ]
367
369
if not checked :
368
370
# This optimizes the case where everyone connects to a fresh game at the same time.
@@ -371,7 +373,8 @@ def get_checked(self, state: typing.Dict[typing.Tuple[int, int], typing.Set[int]
371
373
location_id in self [slot ] if
372
374
location_id in checked ]
373
375
374
- def get_missing (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int ):
376
+ def get_missing (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int
377
+ ) -> typing .List [int ]:
375
378
checked = state [team , slot ]
376
379
if not checked :
377
380
# This optimizes the case where everyone connects to a fresh game at the same time.
@@ -380,7 +383,8 @@ def get_missing(self, state: typing.Dict[typing.Tuple[int, int], typing.Set[int]
380
383
location_id in self [slot ] if
381
384
location_id not in checked ]
382
385
383
- def get_remaining (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int ):
386
+ def get_remaining (self , state : typing .Dict [typing .Tuple [int , int ], typing .Set [int ]], team : int , slot : int
387
+ ) -> typing .List [int ]:
384
388
checked = state [team , slot ]
385
389
player_locations = self [slot ]
386
390
return sorted ([player_locations [location_id ][0 ] for
@@ -391,7 +395,14 @@ def get_remaining(self, state: typing.Dict[typing.Tuple[int, int], typing.Set[in
391
395
if typing .TYPE_CHECKING : # type-check with pure python implementation until we have a typing stub
392
396
LocationStore = _LocationStore
393
397
else :
398
+ try :
399
+ import pyximport
400
+ pyximport .install ()
401
+ except ImportError :
402
+ pyximport = None
394
403
try :
395
404
from _speedups import LocationStore
396
405
except ImportError :
406
+ warnings .warn ("_speedups not available. Falling back to pure python LocationStore. "
407
+ "Install a matching C++ compiler for your platform to compile _speedups." )
397
408
LocationStore = _LocationStore
0 commit comments