python: what is hashability? (intermediate) anthony explains

  Рет қаралды 4,178

anthonywritescode

anthonywritescode

Күн бұрын

today I talk about what it means to be "hashable" and how to define your own `__hash__` method (or disable it!)
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!

Пікірлер: 7
@LSHDackel
@LSHDackel 3 жыл бұрын
Awesome as usual! Especially the edge cases and the difference between the different implementations.❤️
@Nixxen
@Nixxen 3 жыл бұрын
Oooh that film length. Smooth.
@danielalvesldiniz
@danielalvesldiniz Жыл бұрын
when I write a __hash__ for some class Foo I usually do it like def __hash__(self): return hash( (type(self), self.x, self.y) ) because if I just hash the tuple (self.x, self.y) a Foo with x=3 and y=4 will have the same hash of the tuple (3, 4) which is... weird, I guess? I'm not sure that including self's class is "the right way" to implement __hash__, though haha I hope it's not a noob practice
@chasengonzales85
@chasengonzales85 2 жыл бұрын
Thank you very helpful
@onlylearning1959
@onlylearning1959 3 жыл бұрын
Thanks
@StanislavSchmidt1
@StanislavSchmidt1 3 жыл бұрын
It seems that in cpython the default hash is hash(c) == id(c) >> 4. From stackoverflow.com/a/11324771 Thanks for your videos Anthony, really nice and informative.
@anthonywritescode
@anthonywritescode 3 жыл бұрын
dang I was so close to getting this while recording, ah well
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 131 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 13 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 1,8 МЛН
super/MRO, Python's most misunderstood feature.
21:07
mCoding
Рет қаралды 220 М.
module level __getattr__ (intermediate) anthony explains #509
8:07
anthonywritescode
Рет қаралды 6 М.
a python plugin system via entrypoints (intermediate) anthony explains #128
15:04
how does python's module `__getattr__` actually work?
17:38
anthonywritescode
Рет қаралды 5 М.
python 3.13 release highlights
49:56
anthonywritescode
Рет қаралды 21 М.
The Quest To Make Unbreakable Glass
22:23
Veritasium
Рет қаралды 2,3 МЛН