Lisandro Dalcin wrote:
> On Fri, Oct 23, 2009 at 11:25 AM, Stefan Behnel wrote:
>> Lisandro Dalcin wrote:
>>> Patch updated: 
>>> http://trac.cython.org/cython_trac/attachment/ticket/417/typetest.diff
>> Ah, yes, that's a smart way of doing it.
>>
>> Just one thing: are there cases where this may lead to multiple evaluation
>> of the tested expression? I doubt it, since Python values tend to live in
>> temp variables, but I'm not sure how this interacts with C function calls,
>> for example.
>>
> 
> Can you provide a bit code about what you are talking? (then i could
> integrate such cases in the test)

I was thinking of ticket 404 that Robert fixed.

http://trac.cython.org/cython_trac/ticket/404

It might be worth adding a test like this:

  cdef int count = 0

  cdef object getFoo()
      global count
      count += 1
      return Foo()

  def test_getFoo():
      cdef int old_count = count
      cdef Foo x = getFoo()
      return count - old_count

  def test_getFooCast():
      cdef int old_count = count
      cdef Foo x = <Foo?>getFoo()
      return count - old_count

  >>> test_getFoo()
  1
  >>> test_getFooCast()
  1

Just add that and I'll happily await your commit.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to