| 348 | |
| 349 | |
| 350 | class _DictCache(dict): |
| 351 | def __init__(self, nslots: int) -> None: |
| 352 | if nslots < 1: |
| 353 | raise ValueError("Invalid number of slots: %d" % nslots) |
| 354 | self.nslots = nslots |
| 355 | super().__init__() |
| 356 | |
| 357 | def __setitem__(self, key: Any, value: Any) -> None: |
| 358 | # Check if we are running out of space |
| 359 | if len(self) > self.nslots: |
| 360 | warnings.warn( |
| 361 | "the dictionary of node cache is exceeding the recommended " |
| 362 | "maximum number (%d); be ready to see PyTables asking for " |
| 363 | "*lots* of memory and possibly slow I/O." % (self.nslots), |
| 364 | PerformanceWarning, |
| 365 | ) |
| 366 | super().__setitem__(key, value) |
| 367 | |
| 368 | |
| 369 | class NodeManager: |