Функция hash() в Python позволяет вычислять хеш-значения для различных объектов. Обычно для целых чисел хеш совпадает с их значением, но есть исключения, которые могут удивить даже опытных программистов.
Разбираем, почему hash(-1) и hash(-2) в CPython возвращают одинаковое значение. Рассмотрим особенности работы hash(), внутреннюю реализацию хэширования целых чисел и причину специальной обработки -1.
Вопрос:
Что выведет функция hash() для следующих значений: 1, 0, -1, -2?
The next time you visit YouTube, walk past the clickbait and seek out the voices that matter: the kathoey themselves. Their videos might not always have dramatic thumbnails or millions of views, but they offer something far more valuable—truth.
However, the popularity of content tagged with terms like "ladyboy" also highlights the persistence of the fetishization of Asian women. The YouTube algorithm often funnels viewers toward content that caters to the male gaze, potentially reducing complex human beings to objects of desire. Yet, many savvy creators subvert this expectation. While they may utilize beauty and fashion—traditionally feminine aesthetics—to draw viewers in, they often pivot to discussions on legal rights, family acceptance, and the economic struggles of being kathoey in Thailand. By engaging with the audience that the search term "ladyboy" attracts, these creators have the opportunity to educate and humanize a demographic that is frequently dehumanized. u tube thai lady boys
: Despite social tolerance, they cannot legally change their gender on official documents, and they often lack specific anti-discrimination protections in the workplace. The next time you visit YouTube, walk past
The search query "u tube thai lady boys" acts as a digital gateway into one of the most visible yet misunderstood communities in Southeast Asia. While the terminology—specifically the phrase "ladyboy"—is considered pejorative or fetishistic in many Western contexts, it translates to kathoey , a distinct gender identity in Thailand that encompasses transgender women. YouTube, as a global platform, has become a critical arena where the kathoey community navigates the tension between cultural visibility and the Western gaze. Through vlogs, beauty tutorials, and documentary features, Thai transgender women have utilized the platform to reclaim their narratives, challenge stereotypes, and expose the world to the complexities of their lives. The YouTube algorithm often funnels viewers toward content
In YouTube’s early years, most “Thai ladyboy” videos were short clips from Pattaya, Bangkok, or Phuket. Common themes included:
Note to the reader: Language shapes perception. Using respectful, accurate terms like kathoey or transgender woman honors the dignity of Thai gender-diverse people. Let’s be part of the change, one search at a time.
YouTube content featuring the Thai transgender community, often referred to as or ladyboys , typically focuses on cultural education, personal stories, and the entertainment industry. Popular Content Categories
hash() может показаться незначительной, важно помнить о ней при работе с хэш-функциями и структурами данных, основанных на хэшировании. В большинстве случаев вы не столкнетесь с проблемами, но знание этой детали поможет вам избежать потенциальных ошибок и лучше понимать внутреннее устройство Python.Ключевые выводы:
Для небольших целых чисел в Python используется оптимизация (интернирование).
hash(x) == x для большинства целых чисел, но hash(-1) == -2 из-за внутренней реализации и для предотвращения коллизий.
Это поведение является специфичным для CPython и может отличаться в других реализациях Python (например, PyPy).
Используйте == для сравнения значений и is для сравнения идентичности объектов.
Надеюсь, теперь эта загадка с hash(-1) стала немного понятнее!
hash(-1) всегда возвращает -2, поэтому hash(-1) == hash(-2).__hash__() в пользовательских классах.