Create Iso By Froggy Access

Загадочная функция hash в Python

Функция hash() в Python позволяет вычислять хеш-значения для различных объектов. Обычно для целых чисел хеш совпадает с их значением, но есть исключения, которые могут удивить даже опытных программистов. 

Разбираем, почему hash(-1) и hash(-2) в CPython возвращают одинаковое значение. Рассмотрим особенности работы hash(), внутреннюю реализацию хэширования целых чисел и причину специальной обработки -1.

Вопрос на интервью

Однажды на собеседовании мне задали, казалось бы, простой вопрос.

Вопрос:


Что выведет функция hash() для следующих значений: 1, 0, -1, -2?

Create Iso By Froggy Access

This article explores the legacy of Froggy’s ISO tools, why they were so popular, how they work, and how you can still use them today for specific legacy tasks. "Froggy" is the handle of a developer (or development group) who released a suite of freeware utilities primarily in the late 1990s and early 2000s. Unlike commercial giants such as Nero, Roxio, or Adaptec, Froggy’s tools were stripped down to the absolute essentials. They didn't come with massive installation suites, background processes, or "helper" apps that slowed down your computer.

If you wanted to create an ISO file back then, your options were usually limited to expensive CD/DVD burning suites like Nero Burning ROM or Easy CD Creator. These were powerful, but they were massive. A user simply wanting to turn a folder of files into a single archive file (an ISO) had to install 500MB of software, toolbars, and drivers. create iso by froggy

If you are archiving a software installer, create a folder on your desktop named MyProject . Inside, place your setup.exe , readme.txt , and any subfolders. 2. Launching the Application Upon launching the CreateISO.exe (or similarly named executable), you are greeted with a no-nonsense interface. It usually consists of a few text boxes and buttons. There are no wizards or "friendly" cartoons asking you what you want to do today. 3. Selecting the Source You select the Source Directory . This tells the software, "I want everything inside this folder to be put onto the disc image." It is crucial to note that early versions of the tool would create the ISO based on the contents of the folder, not the folder itself This article explores the legacy of Froggy’s ISO

The most famous of these utilities was , a simple executable that allowed users to generate standard ISO-9660 disc images from files on their hard drive. A user simply wanting to turn a folder

While modern operating systems like Windows 10 and 11 have integrated ISO mounting and disc image utilities, there was a golden era where third-party tools were essential. Among these, the utilities developed by a programmer known as "Froggy" stood out as some of the most efficient, reliable, and user-friendly tools ever coded.

The "Froggy" branding was distinctive. The icons were often whimsical, featuring cartoon frogs, a stark contrast to the sterile corporate aesthetic of the time. This personality, combined with the sheer utility of the software, garnered a loyal following on forums, BBS boards, and early download repositories like Simtel and Download.com. To understand why people still search for "create ISO by Froggy," you have to understand the software landscape of the early 2000s.

In the vast and occasionally dusty archives of the internet, few utilities hold the cult status of the collection known simply as "Froggy." For system administrators, retro-computing enthusiasts, and IT professionals who came of age in the early 2000s, the phrase "create ISO by Froggy" brings back a wave of nostalgia. It represents a time when software was lightweight, free of bloat, and did exactly what it said on the tin—often with a charming amphibian icon.

Хотя эта особенность hash() может показаться незначительной, важно помнить о ней при работе с хэш-функциями и структурами данных, основанных на хэшировании. В большинстве случаев вы не столкнетесь с проблемами, но знание этой детали поможет вам избежать потенциальных ошибок и лучше понимать внутреннее устройство Python.

Ключевые выводы:

  • Для небольших целых чисел в Python используется оптимизация (интернирование).
     

  • hash(x) == x для большинства целых чисел, но hash(-1) == -2 из-за внутренней реализации и для предотвращения коллизий.
     

  • Это поведение является специфичным для CPython и может отличаться в других реализациях Python (например, PyPy).
     

  • Используйте == для сравнения значений и is для сравнения идентичности объектов.

Надеюсь, теперь эта загадка с hash(-1) стала немного понятнее!

Вопросы

Почему значения hash(-1) и hash(-2) могут совпадать в Python?
Можно ли изменить поведение функции hash() для чисел?

Поделиться

Обсудить проект с командой LighTech

Забронировать встречу

Примеры реализации проектов

Обсудить проект
Имя
Связаться
Сообщение
Прикрепить файл +
Запрос на получение файлов
Имя
Отправить файлы
Сообщение
Спасибо!
Ваша заявка отправлена
После обработки наш менеджер свяжется с вами