Questions tagged [object-identity]

whether two variable are referring to the same object.

Identity is a property of an object that uniquely defines its abstract location.

Two objects stored in variable a and b are said to have the same identity, if a and b actually refer to the same object (same class, same abstract memory location). On can test identity of two objects using

As an implementation detail, identity hints about potential co-location of objects in physical or virtual memory, and thus may be related to performance. In some languages, one can get a value representing the object's identity, or address (although this token is only valid during the object's lifetime):

54 questions
1
vote
1 answer

How can I register 2 dependencies with the same abstract interface in my factory resolver?

I have a dependency container, that looks like this - public protocol DependencyContainer { typealias FactoryClosure = (Self) -> AnyObject func register(type: Service.Type, closure: @escaping FactoryClosure) func…
Harry Blue
  • 4,202
  • 10
  • 39
  • 78
1
vote
2 answers

In Python, does this expression "(a is b) == ( id(a) == id(b) )" always return True?

In Python, the expression (a is b) == ( id(a) == id(b) ) appears to always returns True, where a and b are variables referring to some object, since the id function returns the memory where they are stored and is is used for object identity. Are…
1
vote
2 answers

Why does ASP.NET viewstate lose identity of serialized objects?

Short question: When I put one and the same instance of an object inside viewstate twice, upon deserialization there are two instances. I want there to be just one instance. Can this be done and how? Wordy explanation: Consider the following…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
1
vote
1 answer

Regular expression for ignoring the First set of letters or a word in a object name in python

" :NYSE Connect_LCAppendedButton " is the object name in our application which keeps changing. The set of words before _LCAppendedButton keeps changing according to our application needs. How do we ignore those set of word "NYSE Connect" or replace…
Brother85
  • 73
  • 3
  • 10
1
vote
3 answers

How to implement Update operation in simple repository in C#

My C# application uses the Repository Pattern, and I have a terrible doubt as how to implement the "Update" part of CRUD operations. Specifically, I don't know how to "tell" the repository which object I want to replace (so that persistence can be…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
1
vote
2 answers

A duck-typing library for C# that doesn't break object identity?

It's been concerning me that the duck-typing libraries I can find for C# all breaks object identity, ie Object.ReferenceEquals returns false for a duck-typed object and its original object. It seems impossible to achieve a wrapper/proxy-less…
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
1
vote
2 answers

mongoDB wont allow me to update

Ok this issue is driving me nutts, I thought that _id was meant to be ObjectID while the first time it inserts it does it correctly when I try to update it using the _id it does not work. here is my code //Save Data function savedata($data){ …
RussellHarrower
  • 6,470
  • 21
  • 102
  • 204
1
vote
2 answers

which is best for performance while referring using _id? While retrieving using _id, i am getting error INVALID OBJECT ID

How should i refer a collection in another collection , a unique username or default _id (object id) or a normal id that increments when a new record is inserted . I read that object ids increase performance in mongoose , but i am unable to retrieve…
user1305989
  • 3,231
  • 3
  • 27
  • 34
0
votes
1 answer

$all parameter in mongodb does not work with ObjectId list

I retrieve a list of ObjectId and I want to retrieve all object in my mongo database using the parameter $all I'm using pymongo and my request look like this : db.database.collection.find({ "_id" : { "$all" :…
kschaeffler
  • 4,083
  • 7
  • 33
  • 41
0
votes
3 answers

How do I create two objects in Python with different identities but the same value?

I can't seem to be able to create two strings that have the same value but different identities. I'm using PyCharm 2023.1 and I'm very new to Python, I've just learned about the difference between == and is operators and I want to actually see the…
0
votes
0 answers

Python id vs is operator behavior difference

According to Python id documentation returns the object's identity which in CPython is its memory address, and the is operator checks if two objects are identical (which I assume should be in the same RAM memory). Consider the snippet below: >>> a =…
0
votes
1 answer

Preserve object identity in parent-child relations of a Hibernate model

I have the following scenario and could not find any solution for this so far. Imagine the following Hibernate model consisting of 3 different types with one-to-many relations: public class A { @Transient private String someRuntimeData; …
godsim
  • 181
  • 1
  • 9
0
votes
0 answers

Is method reference guaranteed to evaluate to the same object?

class A { void b() {} } A a = new A(); Runnable c = a::b; Will c be the same object every time it's initialized?
0
votes
2 answers

RSpec: How to compare have_received arguments by object identity?

i used to using expect(subject/double).to haved_received(:a_method).with(args).exactly(n).times to test that a method be called with some specific arguments and be called exactly {n} times. But today it's broken with arguments are Comparable…
Lam Phan
  • 3,405
  • 2
  • 9
  • 20
0
votes
1 answer

Jackson combining @JsonIdentityInfo and @JsonTypeInfo throws InvalidTypeIdException

Currently I am having an issue with Jackson when I combine @JsonIdentityInfo and @JsonTypeInfo. The Kotlin code below throws an exception on the last line. It serializes the dog1AndDog1Json instance as expected into Json but it then throws an…
Daniel K.
  • 5,747
  • 3
  • 19
  • 22