Robert Bradshaw:
> On Nov 24, 2009, at 4:25 PM, Lisandro Dalcin wrote:
>
>> On Tue, Nov 24, 2009 at 7:47 PM, Joachim Saul <[email protected]>
>> wrote:
>>> Indeed, Pyrex compatibility is a requirement for me. I want to use/
>>> test
>>> the Cython-generated code but need to be able to revert to Pyrex in
>>> case
>>> of problems.
>> What kind of problems are you worried about? Could you elaborate on
>> this?
>
> I'm curious too.
"in case of problems" - I haven't encountered any so far but last time
when I tried a couple months ago I did run into issues that forced me to
postpone the migration from Pyrex to Cython. Now with 0.12 things have
improved quite considerably. Yet it makes me sleep better if during the
transition I can translate the codes with both Pyrex and Cython, Pyrex
being the fallback.
>>> Anyway, what I have done is
>>>
>>> def foo(bytes bar=bytes("")):
>>> c_foo(bar)
>>>
>> Can you try this: ?
>>
>> def foo(bytes bar=b""):
>> c_foo(bar)
>
> I could be wrong, but I don't think Pyrex supports the b prefix on
> strings.
That's the point.
> BTW, it be easier to just do
>
> def foo(bar=""):
> c_foo(bar)
True, but the resulting code then lacks the static typing I want here
for consistency with the rest of the code. Plus, as pointed out by
Stefan Behnel, it is not portable to Python 3.
I would assume that in addition to None, any value that is acceptable as
argument to bytes() should also be acceptable as a default value for a
bytes-type parameter, following the Rule of Least Surprizeā¢. This would
consequently also allow code such as
def foo(bytes bar=5):
unless forbidden in Python 3.
I am not yet very much into Cython and much less the internals, so this
is just from a rather naive user's perspective, and I recognize that
there may very well be points speaking against it.
Cheers,
Joachim
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev