[CC-ing cython-dev]

Lisandro Dalcin, 16.12.2010 23:03:
> On 16 December 2010 18:53, Stefan Behnel wrote:
>> Lisandro Dalcin, 16.12.2010 22:33:
>>>
>>> Just a few comments about this changeset:
>>>
>>> changeset:   4244:e0508ac59b35
>>> user:        Stefan Behnel
>>> date:        Thu Dec 16 20:11:29 2010 +0100
>>> summary:     provide 'builtins' builtin module in -3 mode
>>>
>>>
>>> IIUC, under -3 we can use both "__builtin__" and "builtins", but under
>>> -2 only "__builtin__". Why not to also provide "builtins" under -2
>>> mode? We are already supporting "builtins" in some parts, for example
>>> at ModuleNode.py, method "generate_type_import_call()" ...
>>
>> Well, as long as it actually means that users can import any of the two in
>> their code and have it work at runtime in both Py2 and Py3?
>
> Yes, of course...
>
>> But that would
>> require that Cython changes the user imported module name depending on the C
>> compile time environment. I'm not sure that's a good idea.
>
> Well, the code at generate_type_import_call() work along these lines,
> right? I mean, it translates __builtin__ and builtins to the right
> name in the C runtime.

But that's only when it actually runs in Py3, which is still in "eventual 
migration" state for many users. As long as you keep your code in a Py2 
environment and only "import __builtin__", Cython won't do any magic behind 
your back.


>> The problem I see is that users may have a "builtins" module lying around
>> somewhere in their Py2 code base that Cython would misinterpret and wouldn't
>> be able to import. "builtins" isn't that a bad name for a module, e.g. in a
>> plugin environment...
>
> Yes, you have a good point. However the import would need to be
> absolute for Cython to misinterpret it, right? I would argue that such
> code smells...

It didn't smell all that much before Py3 renamed the module.

Anyway, I'm +0 on changing this. Let's hear what the others think.

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to