returning a value from a thread

J

Jeff Epler

I still have a question. Is the GIL necessary even if there is
no sharing of data between threads?

Data is always shared between threads. One object you're almost certainly
sharing between threads is "None". In the CPython implementation, None
has a refcount just like any other object, and that refcount is modified
in any statement involving None, and by the implicit "return None" at
the end of a function.

The GIL has the effect (among other things) of ensuring that changes to
refcounts are serialized among threads.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFA++/8Jd01MZaTXX0RAvsrAJ9p8hv73VuAx70cXIbVwTkChSixQwCfaK3f
3TqSTTebPaORxxntjV46g18=
=fmrN
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,663
Latest member
josh5959

Latest Threads

Top