How to convert from a tuple to a vec or varray in Hacklang? - Stack Overflow
c# - Tuple's GetHashCode hack - Stack Overflow
Hacker Rank Tuple Problem
Best practice? Function returning a struct, tuple, or void with argument references?
((h1 << 5) + h1) is equivalent to h1 * 33 and 33 is 3 * 11.
Java uses 31 in some hashes since it's prime and h1 * 31 is (h1 << 5) - h which is almost the same, but without additional overflows which might happen in case of sum.
Found something here here
Read the section on Shift-Add-XOR hash
When writing a function that works best if it returns multiple values at once, is it typically better to return those values through a struct (that might exist only for this method), a tuple, or have it be a void function that takes reference arguments which are used as return values?
class MyTuple(object):
def __init__(self, iterable):
self.data = tuple(iterable)
def __getitem__(self, i):
return tuple.__getitem__(self.data, i)
t = MyTuple((1, 2, 3))
print(t[1])
print(isinstance(t, tuple))
Other methods analogously.
Still not a true tuple performancewise, but the closest I can think of... probably.
The main problem you'll hit with performance is that Python's underlying collateral is implemented in highly-optimized C (or other language -- there are a dozen or so good implementations, and more coming).
When you implement something in Python, remember that it's interpreted, or partially-compiled at best. You cannot get optimum performance when each line has to be reinterpreted at run time, even given good intermediate code.