<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def batch(self):
 """A context manager for when you're creating lots of state. Reads will be much slower in a batch, but writes will be faster. You *can* combine this with ``advancing`` but it isn't any faster. """

        if self._no_kc:
            raise ValueError("Already in a batch")
        self._no_kc = True
        yield
        self._no_kc = False