class_docstr: lightweight stream wrapper that implements peek()
class_docstr_tok: ["lightweight","stream","wrapper","that","implements","peek","(",")"]
code: def peek(self, n):
      stream = self.stream
      try:
          if hasattr(stream, "flush"):
              stream.flush()
          position = stream.tell()
          stream.seek(position)  # assert seek() works before reading
          chunk = stream.read(n)
          stream.seek(position)
          return chunk
      except (AttributeError, OSError):
          raise NotImplementedError(
              "stream is not peekable: %r", stream
          ) from None
  
imports: import re
  import os
  import sys
  import warnings
  from dill import _dill, Pickler, Unpickler
  from ._dill import BuiltinMethodType, FunctionType, MethodType, ModuleType, TypeType, _import_module, _is_builtin_module, _is_imported_module, _main_module, _reverse_typemap, __builtin__
  from typing import Optional, Union
  import pathlib
  import tempfile
label_desc: Use image node_id 6 for calling the _PeekableReader obj's underlying member method code with example usage: obj.peek(n) and returns: chunk