> Whenever it's necessary. For a comparison, for example; on assignments, or
> when passing parameters to a function. You can see it in the generated C code,
> which is actually designed to be readable by humans.

I've been using the -a flag and squinting at the generated C code --
it really helps with understanding what's going on!

>  python -m timeit -s 'import pyximport; pyximport.install(); \
>        from mycythonmodule import myfunction'    'myfunction(somearg)'

Thx!

> Who needs setters when you can modify "this" directly?
>
>        >>> def test():
>        ...     a = []
>        ...     def get(i):
>        ...             return a[i]
>        ...     return get
>        >>> get = test()
>        >>> get.func_closure[0].cell_contents.append(123)
>        >>> get(0)
>        123

Hehe =)

This bit of code protects against that: http://paste.lisp.org/display/70003

> Use a "cdef class" in Cython instead. It's implemented in C, so you need to
> modify the class instance memory at the C level in order to change the object
> in other ways than you allow. That's not secure, untrusted code may do that,
> but it's not trivial and therefore pretty unlikely at least.

Untrusted code is pure Python only =)

On a separate note, I am having trouble with dynamically returning a
method (function) via __getattribute__. I'd like to be able to
dynamically return attributes like __str__/__len__ -- and for them to
be used by the likes of str(), len(), etc.

Is there some way of doing this? At the moment, the __str__ returned
by my __getattribute__ is just ignored by str().

And in the only google result exploring the problem,
http://mail.python.org/pipermail/python-list/2004-April/259971.html --
Greg suggests Pyrex (this was years ago), but does not explain how it
could be used in a dynamic setting...

Thanks!

-- 
love, tav

plex:espians/tav | [EMAIL PROTECTED] | +44 (0) 7809 569 369
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to