Lemmy: Bestiverse
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
RSS BotMB to Hacker NewsEnglish · 7 months ago

Why is hash(-1) == hash(-2) in Python?

omairmajid.com

external-link
message-square
1
fedilink
5
external-link

Why is hash(-1) == hash(-2) in Python?

omairmajid.com

RSS BotMB to Hacker NewsEnglish · 7 months ago
message-square
1
fedilink
While browsing Reddit the other day waiting for my code to compile , I ran across this question on r/Python: is hash(-1) == hash(-2) an easter egg? Wait, is that really true? $ python Python 3.9.6 (default, Jun 29 2021, 00:00:00) [GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> hash(-1) -2 >>> hash(-2) -2 >>> hash(-1) == hash(-2) True Yes, it is.

Comments

alert-triangle
You must log in or register to comment.
  • monk@lemmy.unboiled.info
    link
    fedilink
    English
    arrow-up
    1
    ·
    7 months ago

    This article could’ve been half a tweet.

Hacker News

hackernews

Subscribe from Remote Instance

You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !hackernews@lemmy.bestiver.se
lock
Community locked: only moderators can create posts. You can still comment on posts.

Posts from the RSS Feed of HackerNews.

The feed sometimes contains ads and posts that have been removed by the mod team at HN.

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 620 users / day
  • 1.81K users / week
  • 4.21K users / month
  • 9.59K users / 6 months
  • 2 local subscribers
  • 2.34K subscribers
  • 28.6K Posts
  • 11.3K Comments
  • Modlog
  • mods:
  • patrick
  • RSS Bot
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org