Lisandro Dalcín, 22.12.2009 14:47:
> While testing type inference in mpi4py, I noticed that code like the
> one below is failing in the last line. It seems that in Py>=2.6,
> Python makes a coercion on "kw" and builds an actual dict instance
> before calling.
>
> class Foo:
> def view(self, **kw):
> print (kw)
> for k in kw.keys():
> print (k)
>
> Foo().view(a=0, b=1, c=2)
>
> class MyDict(object):
> def __getitem__(self, k):
> assert k == 'a'
> return 7
> def keys(self):
> return ['a']
>
> Foo().view(**MyDict()) # <-- Here is the issue
>
>
> Running on Py>=2.6, the code above gives:
>
> {'a': 0, 'c': 2, 'b': 1}
> a
> c
> b
> {'a': 7}
> a
>
> so that makes me think that at some point Python is building a tmp
> dict out of MyDict instance.
Interesting. So, what's your point? It didn't work before and it works now
by passing in a real dict. Does this impact Cython in any way?
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev