A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2019-January/156074.html below:

[Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?

[Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object? [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jan 18 18:02:53 EST 2019
MRAB wrote:
  If I want to cache some objects, I put them in a dict, using the id as
> the key. If I wanted to locate an object in a cache and didn't have 
> id(), I'd have to do a linear search for it.

That sounds dangerous. An id() is only valid as long as the object
it came from still exists, after which it can get re-used for a different
object. So when an object is flushed from your cache, you would have
to chase down all the places its id is being stored and eliminate them.

Are you sure you couldn't achieve the same thing more safely using
weak references?

-- 
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4