1cdef class C:
2    cdef int i
3
4    def foo(self):
5        self.i = 42
6
7    def get_i(self):
8        return self.i
9
10
11def cast_cast_cast(arg):
12    """
13    >>> x = C()
14    >>> x.foo()
15    >>> cast_cast_cast(x) == x
16    True
17    >>> x.get_i()
18    42
19    """
20    cdef object x
21    cdef void *p = <void *>arg
22    cdef int i
23    x = <object>p
24    p = <void *>x
25    x = (<object>p).foo
26    i = (<C>p).i
27    (<C>p).i = i
28    return <object>p
29