Python bugs

Bjorn Pettersen bjorn at
Mon Nov 29 16:44:31 EST 1999

>     Bjorn> Which is a good thing, but shouldn't preclude it 
> from being used
>     Bjorn> as a dictionary in the update statement (although the fix
>     Bjorn> probably have to be to Dict.update rahter than os.environ).
> You are correct.  It would have to make some assumptions 
> about how to get a
> dict from an instance object.  Should it access the 
> instance's "__dict__"
> attribute or (in this case) the "data" attribute or try to an 
> "as_dict"
> method?  Since no such well-defined interface currently exists, you're
> probably better off in the short term simply executing
>     d.update(

How about:

	def update(self, other):
		... regular stuff
			for k in other.keys():
				self[k] = other[k]

That should be well defined enough, or raise the appropriate exception if it
can't be done.(?)

>     Bjorn> Cool (do you know if you can do db.items() also? 
> -- found that
>     Bjorn> one five minutes ago...)
> I don't see it, and I doubt it's going to get added any time 
> soon.  One
> motivation for using on-disk mappings such as provided by 
> bsddb and (g)dbm
> is that they can be really huge (hundreds of thousands or 
> millions of keys
> are not out of the question).  Asking for values() or items() in these
> situations is much more likely to get you into memory trouble than for
> simple dicts which tend to be smaller.

[workarounds snipped]

Yes, all of these are easy to work around if you really need to -- the point
being you shouldn't need to <0.1 wink>

It's true that on-disk mappings can get huge.  It's also true that sometimes
they're just used for convenient persistence of moderately sized data.  I
think it's generally a bad idea to try to prevent people from potentially
shooting themselves in the foot :-)


More information about the Python-list mailing list