Skip to content

Can we read python class attribute without gil in Rust? #2716

Answered by birkenfeld
noonchen asked this question in Questions
Discussion options

You must be logged in to vote

No, this is not possible. Among other things, there is no &bool that would change, since Python bool objects are immmutable. Reassigning f.stop = True sets the "stop" entry in f.__dict__ to the True object instead of the False object.

However, what you may be able to do is to move setting the stop flag to Rust, by providing a method/function set_stop_flag() implemented in Rust. Then, you can set an actual Rust bool flag (well, probably AtomicBool) and check it cheaply from Rust code.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mejrs
Comment options

mejrs Oct 31, 2022
Collaborator

@noonchen
Comment options

@adamreichold
Comment options

@noonchen
Comment options

Answer selected by noonchen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants