2010/11/14 Vitja Makarov <[email protected]>:
> 2010/11/14 Stefan Behnel <[email protected]>:
>> Vitja Makarov, 14.11.2010 07:23:
>>> Is it safe to use keyword_args in KeywordArgsNode instead of copying.
>>
>> It's a dict that gets created internally by Cython, so the only case that
>> can go wrong is when it's passed into user code and reused afterwards in a
>> user visible way. Here, it can get passed into user code more than once, so
>> the question is if CPython propagates changes to it or not. Cython should
>> behave the same.
>>
>> You can test for it being safe by defining a metaclass with __prepare__ in
>> both Python (doctest code) and Cython, modify the keywords dict in all
>> possible places, and check if there is a difference in behaviour between
>> the two.
>>
>> Stefan
>> _______________________________________________
>> Cython-dev mailing list
>> [email protected]
>> http://codespeak.net/mailman/listinfo/cython-dev
>>
>
>
> That seems to be okay. I've added new patch on trac it includes:
> * KeywordArgNode optimization
> * one more test case too see that kwargs aren't changed
>
> vitja.
>
I also want to use KeywordArgsNode in GeneralCallNode.
KeywordArgsNode should be extended to check for multiple values in
keyword_args and starstar_args,
not sure that is a good idea, because of speed. But cpython works this way.
This code works in cython but fails in python:
def foo(**kwargs):
return kwargs
foo(foo=1, **{'foo': 1})
--
vitja.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev