Hi,
On 19 November 2016 at 15:10, Sébastien Pierre
<
sebastie...@gmail.com> wrote:
> One of the call that pops up often in the profiler is "ffi.cast" (because
> it's called so oten), so I was wondering if I could re-use the object and
> reassign an uncast void* pointer. For instance
>
> cobject = ffi.cast("Match*", untyped_pointer)
> ...
> # Here's what I'd like to do
> cobject.set_pointer(other_utyped_pointer)
Sorry, cdata objects are supposed to be immutable, so no. Allowing
that would break other things, e.g. their hash().
Are you using an ffi object loaded by set_source(), or one created by
cffi.FFI()? The former is faster for various things, including
function calls but also ffi.cast().
If you need the last bits of performance you can avoid a dictionary
lookup by calling ``ffi.cast(match_type, untyped_pointer)``, with a
precomputed value of ``match_type = ffi.typeof("Match*")``.
A bientôt,
Armin.