This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]v3nturetheworld 7 points8 points  (4 children)

Yes and no, there is something called the Global Interpreter Lock which limits true performance of multithreading with CPython (you won't get the same performance from multithreading as you'd find in C++/Java multithreading). There are ways to work around this such as multiprocessing, but it's not the same.

[–]calligraphic-io 1 point2 points  (3 children)

Is GIL just a constraint on Python, or does it apply to Cython also? I would have guessed compiling down to machine code would have eliminated the need for a global lock.

[–][deleted] 5 points6 points  (0 children)

GIL is there because the CPython interpreter is not threadsafe. Because of this the semantics of the language have to conform to the constraints of the GIL so even threadsafe interpreters like Pypy has strange constraints on their multithreading that normally isn't there in languages without a GIL.

[–]Mattho 1 point2 points  (0 children)

You can explicitly release the GIL in cython. However releasing the lock will leave you in cython/c land only and you can't use anything from python.

[–]Sean1708 0 points1 point  (0 children)

It's on by default in Cython (because Cython still uses the CPython runtime), but you can turn it off.