I was trying to optimize a class using jitclass. This class receive two objects from two different classes that were optimized with Numba jitclass as well. However, trying to execute this third class using jitclass I receive a message: StopIteration and code stop the execution.
from typing import List from numba import typed, types from numba.core.typing.typeof import typeof from numba.experimental import jitclass from numba.core.types import Array, DictType, ListType, float64, int8, string, int64 import numpy as np from tqdm import tqdm from src.codename.board import Board from src.codename.card import Card from src.codename.strategy import Strategy from src.utils.files import read_embedding from src.utils.paths import ROOT_DIR spec = [ ("_board", Board.class_type.instance_type), ("_strategy", Strategy.class_type.instance_type), ("_current_player", int8), ("_n_cards_for_clue", int8), ] @jitclass(spec) class Game: def __init__(self, board: Board, strategy: Strategy): self._board = board self._strategy = strategy self._current_player = 1 self._n_cards_for_clue = 3 def get_cards(self) -> List[Card]: return self._board.cards @property def n_cards_for_clue(self) -> int: return self._n_cards_for_clue @property def current_player(self) -> int: return self._current_player def _get_not_revealed_cards(self): cards = self._board.cards temp_cards =  for i in range(len(cards)): if ( self._current_player == 1 and cards[i].card_type == 1 and cards[i].revealed == False ): temp_cards.append(cards[i]) if ( self._current_player == 2 and cards[i].card_type == 2 and cards[i].revealed == False ): temp_cards.append(cards[i]) return temp_cards def _select_n_cards_for_clue(self): temp_cards = self._get_not_revealed_cards() selected_cards = self._strategy.select_cards(temp_cards) return selected_cards def _select_clue(self, selected_cards) -> str: ten_k_words = self._board.sampled_words cards = self._board.cards clue = self._strategy.select_clue(cards, selected_cards, ten_k_words) return clue def give_clue(self) -> str: """ Return a clue for a specific group of cards for each player. Return a string as clue. This clue is calculate using various strategy. One of them is minimax using embedding for string. Return ------ clue: str Return a clue for each game round. """ selected_cards = self._select_n_cards_for_clue() clue = self._select_clue(selected_cards) return clue def next_player(self): if self._current_player == 1: self._current_player = 2 else: self._current_player = 1 def reset(self): self._current_player = 1 self._board.selecting_words() def verify_status(self) -> int: cards = self._board.cards cards_1 =  cards_2 =  for i in range(len(cards)): if cards[i].card_type == 1: cards_1.append(cards[i]) if cards[i].card_type == 2: cards_2.append(cards[i]) count_number_1 = 0 for card in cards_1: if card.revealed == True: count_number_1 += 1 if len(cards_1) == count_number_1: return 1 count_number_2 = 0 for card in cards_2: if card.revealed == True: count_number_2 += 1 if len(cards_2) == count_number_2: return 2 return 0