Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4125578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:53:16+00:00 2026-05-20T23:53:16+00:00

Why does None hash to -1042159082 (which I found to be equal to number

  • 0

Why does None hash to -1042159082 (which I found to be equal to number of bytes in a Gigabyte negated)?

I realize this doesn’t really effect my code, but I’m curious.

Hashes are used for dictionary key look-ups, so I decided to experiment:

>>> D = {-1042159082: 'Hello', None: 'Hi'}
>>> D[None]
'Hi'
>>> D[-1042159082]
'Hello'
>>>

I understand this as Python seeing two identical hashes and then checking type to see what’s what. Is that right?

>>> {False: 'Hello', 0: 'Hi'}
{False: 'Hi'}
>>> {0: 'Hi', False: 'Hello'}
{0: 'Hello'}

This is just weird. What’s more is that the first key is kept and the second value is kept.

Is this sorcery, or could somebody help me understand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:53:16+00:00Added an answer on May 20, 2026 at 11:53 pm

    About 2 values which may produce the same output when passed to the built-in hash() function (None and -1042159082 in the question asked):

    This is called a collision (see this page on Wikipedia for more information about collisions).

    The hashing algorithm which Python uses has a special way to figure out which value the person really wants when there is a collision (see this page in the source code of CPython (the main Python interpreter), starting at line 51, for information on collisions for dicts, at the time of writing this answer; this file also has notes on how dicts are implemented).

    About what happens with 0 and False (and more useful info), see other answers to the current question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to hash a password to dump into a .rdp file. I found
EDIT: 1 The following does not work, even after clearing browser cache: .ui-state-hover {background-image:none;background-color:red;color:red;padding:50px;margin:50px;}
Does anyone know why when I run this code in my script it takes
The following snippet applies a #breadcrumb hash to each link once it's clicked. That
I'm performing a thought-experiment which, judging by other questions, isn't so novel after all,
Does anyone have any experience with pjsip on android devices? I see several non-commercial/test
I have implemented a version of Rush Hour (the puzzle board game) in Python
So I was reading the Wikipedia article on the Sieve of Eratosthenes and it
while saving an entity that has reference properties, is it the app's responsibility to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.