| Server IP : 199.250.200.62 / Your IP : 216.73.216.4 Web Server : Apache System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : jasonp18 ( 1000) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/proc/3/task/3/cwd/opt/imh-python/lib/python3.9/site-packages/kombu/utils/ |
Upload File : |
"""Custom maps, sequences, etc."""
from __future__ import annotations
class HashedSeq(list):
"""Hashed Sequence.
Type used for hash() to make sure the hash is not generated
multiple times.
"""
__slots__ = 'hashvalue'
def __init__(self, *seq):
self[:] = seq
self.hashvalue = hash(seq)
def __hash__(self):
return self.hashvalue
def eqhash(o):
"""Call ``obj.__eqhash__``."""
try:
return o.__eqhash__()
except AttributeError:
return hash(o)
class EqualityDict(dict):
"""Dict using the eq operator for keying."""
def __getitem__(self, key):
h = eqhash(key)
if h not in self:
return self.__missing__(key)
return super().__getitem__(h)
def __setitem__(self, key, value):
return super().__setitem__(eqhash(key), value)
def __delitem__(self, key):
return super().__delitem__(eqhash(key))