[rb-general] Addresses in (I)Python output

Daniel Shahaf danielsh at apache.org
Wed Sep 25 20:07:46 UTC 2019


Chris Lamb wrote on Wed, 25 Sep 2019 19:15 +00:00:
> Hi Daniel,
> 
> > Even for documentation builds, removing addresses entirely could have
> > downsides.
> […]
> > 	   >>> hex(id(c.__class__))
> > 	   '0x7352a0'
> > 	   >>> hex(id(cls.C))
> > 	   '0x4198d0'
> 
> Indeed, but I'm not sure we were really suggesting that we normalise
> all "\b0x[0-9a-z]+\b", rather that we patch the "repr"-like routine
> which would not have any affect on the above.

That's my understanding too, but my point stands.  The example I linked
literally uses id(), but the principle applies to examples that use
repr() too, since repr() prints the id() by default.  For example,
I could easily imagine a Redis-like library doing something like:

>>> o = cls.C()
>>> write_to_cache("key", o)
>>> o2 = read_from_cache("key")
>>> o
<cls.C object at 0x42>
>>> o2
<cls.C object at 0x43>
>>> o == o2
True
>>> 

Cheers,

Daniel


More information about the rb-general mailing list