class_docstr: Cache for wcwidth sizes.
code: def __missing__(self, string: str) -> int:
      # Note: We use the `max(0, ...` because some non printable control
      #       characters, like e.g. Ctrl-underscore get a -1 wcwidth value.
      #       It can be possible that these characters end up in the input
      #       text.
      result: int
      if len(string) == 1:
          result = max(0, wcwidth(string))
      else:
          result = sum(self[c] for c in string)
  
      # Store in cache.
      self[string] = result
  
      # Rotate long strings.
      # (It's hard to tell what we can consider short...)
      if len(string) > self.LONG_STRING_MIN_LEN:
          long_strings = self._long_strings
          long_strings.append(string)
  
          if len(long_strings) > self.MAX_LONG_STRINGS:
              key_to_remove = long_strings.popleft()
              if key_to_remove in self:
                  del self[key_to_remove]
  
      return result
  
imports: from __future__ import annotations
  import os
  import signal
  import sys
  import threading
  from collections import deque
  from typing import Callable, ContextManager, Dict, Generator, Generic, TypeVar, Union
  from wcwidth import wcwidth
label_desc: Use image node_id 2 for calling the _CharSizesCache obj's underlying member method code with example usage: obj.__missing__(string) and returns: result