Skip to content

Commit 66dbd15

Browse files
committed
Remove variable scope optimizations
1 parent 23a239b commit 66dbd15

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

chess/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
PIECE_SYMBOLS = [None, "p", "n", "b", "r", "q", "k"]
4747
PIECE_NAMES = [None, "pawn", "knight", "bishop", "rook", "queen", "king"]
4848

49-
def piece_symbol(piece_type: PieceType, _PIECE_SYMBOLS: List[Optional[str]] = PIECE_SYMBOLS) -> str:
50-
return typing.cast(str, _PIECE_SYMBOLS[piece_type])
49+
def piece_symbol(piece_type: PieceType) -> str:
50+
return typing.cast(str, PIECE_SYMBOLS[piece_type])
5151

5252
def piece_name(piece_type: PieceType) -> str:
5353
return typing.cast(str, PIECE_NAMES[piece_type])
@@ -211,18 +211,18 @@ def scan_forward(bb: Bitboard) -> Iterator[Square]:
211211
def msb(bb: Bitboard) -> int:
212212
return bb.bit_length() - 1
213213

214-
def scan_reversed(bb: Bitboard, *, _BB_SQUARES: List[Bitboard] = BB_SQUARES) -> Iterator[Square]:
214+
def scan_reversed(bb: Bitboard) -> Iterator[Square]:
215215
while bb:
216216
r = bb.bit_length() - 1
217217
yield r
218-
bb ^= _BB_SQUARES[r]
218+
bb ^= BB_SQUARES[r]
219219

220220
try:
221221
# Python 3.10
222222
popcount = int.bit_count
223223
except AttributeError:
224-
def popcount(bb: Bitboard, *, _bin: Callable[[int], str] = bin) -> int:
225-
return _bin(bb).count("1")
224+
def popcount(bb: Bitboard) -> int:
225+
return bin(bb).count("1")
226226

227227
def flip_vertical(bb: Bitboard) -> Bitboard:
228228
# https://www.chessprogramming.org/Flipping_Mirroring_and_Rotating#FlipVertically

0 commit comments

Comments
 (0)