Dear python experts,
I use a huge python dictionary where the values are lists of that
dictionary's keys (yes, a graph). Each key is thus referenced several
times.
As the keys are rather large objects, I would like to save memory by
re-using key objects wherever possible, instead of having sever
Chris Rebert writes:
> On Sun, May 15, 2011 at 1:28 AM, Christoph Groth wrote:
>> I use a huge python dictionary where the values are lists of that
>> dictionary's keys (yes, a graph). Each key is thus referenced
>> several times.
>>
>> As the keys are
Steven D'Aprano writes:
> On Sun, 15 May 2011 11:11:41 +0200, Christoph Groth wrote:
>
>> I would like to avoid having _multiple_ objects which are equal (a ==
>> b) but not the same (a is not b). This would save a lot of memory.
>
> Based on the idea of intern
Dear all,
sometimes it is handy to have a function which can take as argument
anything which can be converted into something, e.g.
def foo(arg):
arg = float(arg)
# ...
I would like to mimic this behavior of float for a user-defined type,
e.g.
def bar(arg):
arg = My_type(arg)
#
Bruno Desthuilliers writes:
>> It seems to me that in this way I might get problems when I pass an
>> instance of Derived_from_my_type to bar, as it will become an
>> instance of My_type.
>
> The instance you pass to bar won't "become" anything else. You create
> a new My_type instance from the D
Bruno Desthuilliers writes:
> Anyway: the simplest solution here is to replace the call to your Base
> class with a call to a factory function. I'd probably go for something
> like (Q&D untested code and other usual warnings) :
>
> (...)
Yeah, that will do what I want.
My confusion arose from t
Steven D'Aprano writes:
> On Fri, 18 Jun 2010 16:30:00 +0200, Christoph Groth wrote:
>
>> If other is of type Base already, just "pass it on". Otherwise,
>> construct an instance of Base from it.
>>
>> *