473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Pointer or unique id

Hello,

does python have an equivalent to Java: int Object.hashCode() ?

TIA
--
Nomak
Jul 18 '05 #1
3 1283
Nomak a écrit :
Hello,

does python have an equivalent to Java: int Object.hashCode() ?


id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects. (Hint: it's the object's memory address.)

hash(obj) -> integer
Return a hash value for the object. Two objects with the same value
have the same hash value. The reverse is not necessarily true, but likely.

HTH
Bruno
Jul 18 '05 #2
Bruno Desthuilliers wrote:
hash(obj) -> integer
Return a hash value for the object. Two objects with the same value
have the same hash value. The reverse is not necessarily true, but likely.


Of course not all Python objects are hashable:
hash([])

Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: list objects are unhashable
--
Michael Hoffman
Jul 18 '05 #3

"Bruno Desthuilliers" <bd*****************@free.quelquepart.fr> wrote in
message news:41***********************@news.free.fr...
id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects.
This is part of the language specification. Also, the identity of an
object must remain the same for its entire lifetime.
(Hint: it's the object's memory address.)


This is an implementation detail of CPython. It cannot be true if the
garbage collector moves objects around. Or if the object lives elsewhere
(and is accessed thru a proxy).

Terry J. Reedy

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Al Newton | last post by:
My class has this member function: vector<UniqueCustId*>* CMyClass::GetCustList( void ) { SYSTEMTIME st; string strServiceDate; UniqueCustId* uci = new UniqueCustId; string strCustNumberOld =...
35
by: tuko | last post by:
Hello kind people. Can someone explain please the following code? /* Create Storage Space For The Texture */ AUX_RGBImageRec *TextureImage; /* Line 1*/ /* Set The Pointer To NULL...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
11
by: hilz | last post by:
Hi all: I have a FILE pointer that points to a file on disk (not any other io stream). is there a way to get the filename of that FILE? i thought it would be the _tmpfname part of the struct, but...
5
by: Danilo Kempf | last post by:
Folks, maybe one of you could be of help with this question: I've got a relatively portable application which I'm extending with a plugin interface. While portability (from a C perspective) is...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
13
by: al.cpwn | last post by:
I get that these two are different int* get() { static int m; return &m; } int& get() {
5
by: Scott | last post by:
Hi All, Am I correct in assuming that there is no way to have a base pointer to an object that uses multiple inheritance? For example, class A { /* ... */ }; class B { /* ... */ };
1
by: yadolov | last post by:
I have COM-object with Iface interface: typedef struct { .... } TStruct; interface Iface : IUnknown {
20
by: jason | last post by:
Hello, I'm a beginning C programmer and I have a question regarding arrays and finding the number of entries present within an array. If I pass an array of structures to a function, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.