4 tips for getting started with free-threaded Python

If you create an iterator, don’t attempt to pass it between threads. You can share the objects yielded by an iterator, as long as they’re thread-safe, but don’t share the iterator itself across thread boundaries. For instance, to create an iterator that produces the letters from a string one after the other, you could do this:


data = "abcdefg"
d_iter = iter(data)
item = next(d_iter)
item2 = next(d_iter)
# ... etc.

In this example, d_iter is the iterator object. You could share data and item (or item2, etc.) between threads, but you can’t share d_iter itself between threads, as that’s likely to corrupt its internal state.

Python frame objects contain information about the state of a program at a particular point in its execution. Among other things, they’re used by Python’s debugging mechanisms to produce details about the program when an error condition arises.

Donner Music, make your music with gear
Multi-Function Air Blower: Blowing, suction, extraction, and even inflation

Leave a reply

Please enter your comment!
Please enter your name here