Функция hash() в Python позволяет вычислять хеш-значения для различных объектов. Обычно для целых чисел хеш совпадает с их значением, но есть исключения, которые могут удивить даже опытных программистов.
Разбираем, почему hash(-1) и hash(-2) в CPython возвращают одинаковое значение. Рассмотрим особенности работы hash(), внутреннюю реализацию хэширования целых чисел и причину специальной обработки -1.
Вопрос:
Что выведет функция hash() для следующих значений: 1, 0, -1, -2?
The chapter focuses on the "boroboro" aspect—her extreme exhaustion and hopelessness. The audience feels the weight of her struggles, creating an instant emotional investment in her recovery.
(English: The Apothecary Is Gonna Make This Ragged Elf Happy ) is a dramatic fantasy manga that follows a reclusive apothecary who rescues a severely abused elf slave. Originally a popular webcomic by Gibagibagiba that concluded with 64 chapters, the series received a formal serialization starting in March 2025 published by Shueisha Inc. . Chapter 1 Plot Summary
As of early 2026, the series continues to develop, with discussions surrounding new chapters, including the pivotal first chapter that sets the stage for a heart-warming, albeit mature, story of recovery. The chapter focuses on the "boroboro" aspect—her extreme
is less about the beginning of an adventure and more about the beginning of a recovery. It establishes a contract with the reader: while the world may be cruel, the focus of this story will be the gentle, persistent effort to mend what has been broken. similar manga titles that focus on character rehabilitation and healing?
Instead of an overpowered hero saving the world, a humble merchant saves a single life through everyday care. Originally a popular webcomic by Gibagibagiba that concluded
Chapter 1 wastes no time establishing its roots, blending drama, fantasy, and dark themes. It avoids the typical lightheartedness of "isekai" or "slice-of-life" fantasy, focusing instead on the grueling, slow process of rehabilitation.
For fans diving into , the story sets up a masterclass in the "hurt/comfort" trope, exploring the profound journey of physical and emotional rehabilitation. 📋 Overview of the Series is less about the beginning of an adventure
Here, the manga subverts a common trope. The protagonist does not have a magical “cure-all” potion. He does not have a skill that resets status effects. He is, as he later explains to himself, just a merchant who sells simple remedies for fevers, coughs, and minor wounds. He is out of his depth. And yet, he stays.
The serialization brings highly detailed, expressive character designs that perfectly capture the elf's vulnerability and the apothecary's warmth. Where to Read and Follow Updates
: Information and community tracking for the series can be found on AniList and the Anime News Network Encyclopedia .
The story centers on a skilled apothecary/medicine seller who crosses paths with an elf who has been treated terribly. In Chapter 1, this (boroboro) is found broken, abused, and having lost her will to live after being discarded. The core premise is not just about physical healing, but the slow, patient process of healing emotional scars and restoring the dignity of a being who has been treated as a mere object. The Impact of Chapter 1
hash() может показаться незначительной, важно помнить о ней при работе с хэш-функциями и структурами данных, основанных на хэшировании. В большинстве случаев вы не столкнетесь с проблемами, но знание этой детали поможет вам избежать потенциальных ошибок и лучше понимать внутреннее устройство Python.Ключевые выводы:
Для небольших целых чисел в Python используется оптимизация (интернирование).
hash(x) == x для большинства целых чисел, но hash(-1) == -2 из-за внутренней реализации и для предотвращения коллизий.
Это поведение является специфичным для CPython и может отличаться в других реализациях Python (например, PyPy).
Используйте == для сравнения значений и is для сравнения идентичности объектов.
Надеюсь, теперь эта загадка с hash(-1) стала немного понятнее!
hash(-1) всегда возвращает -2, поэтому hash(-1) == hash(-2).__hash__() в пользовательских классах.