简体   繁体   中英

Set visibility in pure-python Cython code

one of my major problems with cython cdef classes is that all their variables are by default private. When I am converting some python code to pure-python-mode cython, I have to manually use var_name = cython.declare(type, visibility='public) for every variable.

Is it possible to set all cdef class variables to be public by default? If not, do you consider it a good idea, perhaps for feature request?

Not that immediately springs to mind, but you need to do this with a lot of variables you could just make a wrapper like:

import functools
declare_public = functools.partial(Cython.declare, visibility='public')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM