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

  • Home
  • SEARCH
  • 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 9278137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:17:24+00:00 2026-06-18T17:17:24+00:00

I have some points in space where each point has an id . I

  • 0

I have some points in space where each point has an id. I also have a subset of these points in another group that have different id values.

How can I create a new type of id for both groups of points so that the points that have the same coordinates end up using the same id values?

I assume I need to generate hash codes using their coordinates which should give me the same id value for points that have the same coordinates, right?

I am confused how I could use it because the set of hashcodes is much smaller than float[3]. So not sure if I am on the right track.

  • 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-06-18T17:17:25+00:00Added an answer on June 18, 2026 at 5:17 pm

    I’m not completely sure what you mean here, but you could use __hash__ with a tuple:

    class Point(object):
        def __init__(self,x,y,z):
            self.x = x
            self.y = y
            self.z = z
    
        def __hash__(self):
            return hash((self.x,self.y,self.z))
    
        def __eq__(self,other):
            return (self.x,self.y,self.z) == (other.x,other.y,other.z)
    

    Now, objects which contain the same point all hash to the same value. As a side benefit, they can now be used as dictionary keys or in set objects a little bit more reasonably.


    Of course, if you’re going to write a class this simple, you might want to consider a collections.namedtuple instead. You could even subclass it (it’s all spelled out in the link). This has the advantage of the object being immutable — Mutating a hashable object just isn’t a nice thing to do ;-). The objects also have no __dict__ associated with them, so they’ll probably be a little easier on your memory if you’re creating 100M of them.

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

Sidebar

Related Questions

I have some sql statements that calculates some numbers. It's possible (with bonus points/penalty
So I have some function that receives N random 2D points. Is there any
Supose I have a matrix. This matrix is blank except some points that create
At some point I must have moved files from one location to another using
I have many joinable threads that at some point need to all stop. The
I have made a UIView in which I have collected some points into a
I have an HTML5 canvas image where I've drawn some points and I want
HI, I have a Mapview with some marker points + a marker for current
Let's say I have a domain, js.mydomain.com , and it points to some IP
I have written some Python scripts in Eclipse where at some point I have

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.