Spaces:
Running
on
Zero
Running
on
Zero
File size: 480 Bytes
bcc039b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import abc
from typing import Any, Generator, Generic, TypeVar
T = TypeVar("T")
C = TypeVar("C")
class StatefulIterator(Generic[T, C], abc.ABC):
@abc.abstractmethod
def get_state(self) -> C:
pass
@abc.abstractmethod
def create_iter(self) -> Generator[T, Any, None]:
pass
class IteratorState(Generic[C]):
@abc.abstractmethod
def build(self) -> StatefulIterator[T, C]:
pass
|