[Pyrex] Pyrex checks type of literal None argument
Sam Rushing
sam-pyrex at rushing.nightmare.com
Tue May 23 22:31:15 CEST 2006
On Tue, 2006-05-23 at 08:42 +0200, Stefan Behnel wrote:
> I then call it with a literal None as second argument:
>
> value = factory(somepointer, None)
>
> Pyrex generates this code for it:
>
> if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5etree__SomeType)) { ... }
>
> __pyx_2 = ((PyObject *)__pyx_f_5etree_factory(__pyx_v_c_doc,
> ((struct __pyx_obj_5etree__SomeType *)Py_None))); if (!__pyx_2) {...}
>
> I think the type check should be optimised away.
This sounds familiar. Is this it?
ExprNode.coerce_to():
don't emit a PyTypeTestNode() for PyNone, which
always returns '1' anyway... This can speed up
assignments an constructors.
Index: ExprNodes.py
===================================================================
RCS
file: /usr/local/cvsroot/third_party/pyrex/Pyrex/Compiler/ExprNodes.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -r1.3 -r1.4
461c461,462
< src = PyTypeTestNode(src, dst_type, env)
---
> if not isinstance (src, NoneNode):
> src = PyTypeTestNode(src, dst_type, env)
-Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20060523/a58cd74d/attachment.bin
More information about the Pyrex
mailing list