"Stian Soiland" <[EMAIL PROTECTED]> wrote:
> 
> On 7/11/06, Terry Reedy <[EMAIL PROTECTED]> wrote:
> 
> > >>> d={1:'one', 1.0:'one'}
> > >>> d
> > {1: 'one'}
> 
> This highlights the problem. Imagine that you don't type out the
> actual objects, but just receive them:
> 
> def make_dict(x, y, obj):
>     return {x: obj, y: obj}
> 
> x1 = x2 = "fish"
> d = make_dict(x1, x2, 1337)
> 
> 
> Here I don't really care if a and b are the same or not, I just care
> that I can do d[x1] and d[x2].
> 
> (Of course this is a dangerous path to go down too deep, what about
> del d[x1] ? And who would make such code, anyway?)
> 
> 
> Maybe only for the literal values and direct variable names..?
> 
> Is the following behaviour as expected, or is it just The Lock?

It's not related to the GIL at all, it just happens that dict creation
occurred within an entire bytecode 'time slice' (sys.get/setcheckinterval()).


>>> def foo():
...     x = {count-1+1: 1, count: 2, count-1+1: 3, count: 4, count: 5,
... count:6, count: 7, count: 8, count-1+1: 9, count: 10, count: 11}
...     while len(x) == 1:
...             x = {count-1+1: 1, count: 2, count-1+1: 3, count: 4,
... count: 5, count: 6, count: 7, count: 8, count-1+1: 9, count: 10,
... count: 11}
...     return x
...
>>> foo()
{149703626: 11, 149703605: 1}

 - Josiah

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to