How do I get a reference to a KEY value of a dictionary?
Ben Finney
bignose-hates-spam at and-benfinney-does-too.id.au
Thu Jul 31 20:26:12 EDT 2003
On 31 Jul 2003 17:36:41 -0700, Andy C wrote:
> Is this a waste of time? Because I know in python I cannot be certain
> that the argument strings that are read from files are even garbage
> collected anyway. I could certainly do the job with duplicate
> strings, but it would seem wasteful. I am a C programmer, and old
> habits die hard.
Python dynamically binds names ("variables") to objects; many types,
including immutable strings, will not be duplicated if an identical one
is already stored.
The upshot is: store an identical string as many times as you like,
because PYthon will simply keep references to the one string object for
each duplicate.
--
\ "Friendship is born at that moment when one person says to |
`\ another, 'What! You too? I thought I was the only one!'" -- |
_o__) C.S. Lewis |
Ben Finney <http://bignose.squidly.org/>
More information about the Python-list
mailing list