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.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev