🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 152 (from laksa020)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
5 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago (distributed domain, exempt)
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://en.wikipedia.org/wiki/Global_interpreter_lock
Last Crawled2026-04-06 10:29:56 (5 days ago)
First Indexed2015-09-20 11:54:37 (10 years ago)
HTTP Status Code200
Meta TitleGlobal interpreter lock - Wikipedia
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
From Wikipedia, the free encyclopedia Schematic representation of how threads work under GIL. Green - thread holding GIL, red - blocked threads A global interpreter lock ( GIL ) is a mechanism used in computer-language interpreters to synchronize the execution of threads so that only one native thread (per process) can execute basic operations (such as memory allocation and reference counting ) at a time. [ 1 ] As a general rule, an interpreter that uses GIL will see only one thread to execute at a time, even if it runs on a multi-core processor , although some implementations provide for CPU intensive code to release the GIL, allowing multiple threads to use multiple cores. Some popular interpreters that have a GIL are CPython and Ruby MRI . Technical background concepts [ edit ] A global interpreter lock (GIL) is a mutual-exclusion lock held by a programming language interpreter thread to avoid sharing code that is not thread-safe with other threads. In implementations with a GIL, there is always one GIL for each interpreter process . Applications running on implementations with a GIL can be designed to use separate processes to achieve full parallelism, as each process has its own interpreter and in turn has its own GIL. Otherwise, the GIL can be a significant barrier to parallelism. Reasons for employing a global interpreter lock include: increased speed of single-threaded programs (no necessity to acquire or release locks on all data structures separately), easy integration of C libraries that usually are not thread-safe, ease of implementation (having a single GIL is much simpler to implement than a lock-free interpreter or one using fine-grained locks). A way to get around a GIL is creating a separate interpreter per thread, which is too expensive with most languages. [ citation needed ] Use of a global interpreter lock in a language effectively limits the amount of parallelism reachable through concurrency of a single interpreter process with multiple threads. If the process is almost purely made up of interpreted code and does not make calls outside of the interpreter which block for long periods of time (allowing the GIL to be released by that thread while they process), there is likely to be very little increase in speed when running the process on a multiprocessor machine. Due to signaling with a CPU-bound thread, it can cause a significant slowdown, even on single processors. [ 2 ] More seriously, when the single native thread calls a blocking OS process (such as disk access), the entire process is blocked, even though other application threads may be waiting. Some language implementations that implement a global interpreter lock are CPython , the most widely-used implementation of Python , [ 3 ] [ 4 ] and Ruby MRI , the reference implementation of Ruby (where it is called Global VM Lock). JVM -based equivalents of these languages ( Jython and JRuby ) do not use global interpreter locks. IronPython and IronRuby are implemented on top of Microsoft 's Dynamic Language Runtime and also avoid using a GIL. [ 5 ] An example of an interpreted language without a GIL is Tcl , which is used in the benchmarking tool HammerDB . [ 6 ] Example code in Python . Notice how a lock is acquired and released between each instruction call. It uses the Lock object from the threading module. [ 7 ] from threading import Lock INSTRUCTION_TABLE = { ... } def execute ( bytecode : list ) -> None : """Execute bytecode.""" lock = Lock () for ( opcode , args ) in bytecode : lock . acquire () INSTRUCTION_TABLE [ opcode ]( args ) lock . release () Free-Threaded Build (Python 3.13 and later) In Python 3.13, an experimental "free-threaded" build of CPython was introduced as part of PEP 703 – Making the Global Interpreter Lock Optional in CPython . This build allows developers to compile Python without the Global Interpreter Lock (GIL), enabling true parallel execution of Python bytecode across multiple CPU cores. The feature is still experimental but represents a major step toward improved concurrency in future Python releases. [ 8 ] Green threads Giant lock ^ "GlobalInterpreterLock" . Python Wiki . Retrieved 30 November 2015 . ^ David Beazley (2009-06-11). "Inside the Python GIL" (PDF) . Chicago: Chicago Python User Group . Retrieved 2009-10-07 . ^ Shannon -jj Behrens (2008-02-03). "Concurrency and Python" . Dr. Dobb's Journal . p. 2 . Retrieved 2008-07-12 . The GIL is a lock that is used to protect all the critical sections in Python. Hence, even if you have multiple CPUs, only one thread may be doing "pythony" things at a time. ^ "Python/C API Reference Manual: Thread State and the Global Interpreter Lock" . Archived from the original on 2008-09-14 . Retrieved 2014-08-15 . ^ "IronPython at python.org" . python.org . Retrieved 2011-04-04 . IronPython has no GIL and multi-threaded code can use multi core processors. ^ "HammerDB Concepts and Architecture" . HammerDB. 2018-11-30 . Retrieved 2020-05-10 . It is important to understand at the outset that HammerDB is written in TCL because of the unique threading capabilities that TCL brings. ^ "threading — Thread-based parallelism" . Python documentation . Retrieved 16 April 2025 . ^ "PEP 703 – Making the Global Interpreter Lock Optional in CPython | peps.python.org" . Python Enhancement Proposals (PEPs) . Retrieved 2025-11-13 .
Markdown
[Jump to content](https://en.wikipedia.org/wiki/Global_interpreter_lock#bodyContent) Main menu Main menu move to sidebar hide Navigation - [Main page](https://en.wikipedia.org/wiki/Main_Page "Visit the main page [z]") - [Contents](https://en.wikipedia.org/wiki/Wikipedia:Contents "Guides to browsing Wikipedia") - [Current events](https://en.wikipedia.org/wiki/Portal:Current_events "Articles related to current events") - [Random article](https://en.wikipedia.org/wiki/Special:Random "Visit a randomly selected article [x]") - [About Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:About "Learn about Wikipedia and how it works") - [Contact us](https://en.wikipedia.org/wiki/Wikipedia:Contact_us "How to contact Wikipedia") Contribute - [Help](https://en.wikipedia.org/wiki/Help:Contents "Guidance on how to use and edit Wikipedia") - [Learn to edit](https://en.wikipedia.org/wiki/Help:Introduction "Learn how to edit Wikipedia") - [Community portal](https://en.wikipedia.org/wiki/Wikipedia:Community_portal "The hub for editors") - [Recent changes](https://en.wikipedia.org/wiki/Special:RecentChanges "A list of recent changes to Wikipedia [r]") - [Upload file](https://en.wikipedia.org/wiki/Wikipedia:File_upload_wizard "Add images or other media for use on Wikipedia") - [Special pages](https://en.wikipedia.org/wiki/Special:SpecialPages "A list of all special pages [q]") [![](https://en.wikipedia.org/static/images/icons/enwiki-25.svg) ![Wikipedia](https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en-25.svg) ![The Free Encyclopedia](https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-tagline-en-25.svg)](https://en.wikipedia.org/wiki/Main_Page) [Search](https://en.wikipedia.org/wiki/Special:Search "Search Wikipedia [f]") Appearance - [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en) - [Create account](https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Global+interpreter+lock "You are encouraged to create an account and log in; however, it is not mandatory") - [Log in](https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Global+interpreter+lock "You're encouraged to log in; however, it's not mandatory. [o]") Personal tools - [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en) - [Create account](https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Global+interpreter+lock "You are encouraged to create an account and log in; however, it is not mandatory") - [Log in](https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Global+interpreter+lock "You're encouraged to log in; however, it's not mandatory. [o]") ## Contents move to sidebar hide - [(Top)](https://en.wikipedia.org/wiki/Global_interpreter_lock) - [1 Technical background concepts](https://en.wikipedia.org/wiki/Global_interpreter_lock#Technical_background_concepts) - [2 Advantages](https://en.wikipedia.org/wiki/Global_interpreter_lock#Advantages) - [3 Drawbacks](https://en.wikipedia.org/wiki/Global_interpreter_lock#Drawbacks) - [4 Examples](https://en.wikipedia.org/wiki/Global_interpreter_lock#Examples) - [5 Example code](https://en.wikipedia.org/wiki/Global_interpreter_lock#Example_code) - [6 Recent Development](https://en.wikipedia.org/wiki/Global_interpreter_lock#Recent_Development) - [7 See also](https://en.wikipedia.org/wiki/Global_interpreter_lock#See_also) - [8 References](https://en.wikipedia.org/wiki/Global_interpreter_lock#References) Toggle the table of contents # Global interpreter lock 12 languages - [Català](https://ca.wikipedia.org/wiki/Bloqueig_d%27int%C3%A8rpret_global "Bloqueig d'intèrpret global – Catalan") - [Čeština](https://cs.wikipedia.org/wiki/Glob%C3%A1ln%C3%AD_z%C3%A1mek_interpretu "Globální zámek interpretu – Czech") - [فارسی](https://fa.wikipedia.org/wiki/%D9%82%D9%81%D9%84_%D9%85%D9%81%D8%B3%D8%B1_%D8%B3%D8%B1%D8%A7%D8%B3%D8%B1%DB%8C "قفل مفسر سراسری – Persian") - [Français](https://fr.wikipedia.org/wiki/Global_interpreter_lock "Global interpreter lock – French") - [Bahasa Indonesia](https://id.wikipedia.org/wiki/Global_interpreter_lock "Global interpreter lock – Indonesian") - [Italiano](https://it.wikipedia.org/wiki/Global_Interpreter_Lock "Global Interpreter Lock – Italian") - [日本語](https://ja.wikipedia.org/wiki/%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%97%E3%83%AA%E3%82%BF%E3%83%AD%E3%83%83%E3%82%AF "グローバルインタプリタロック – Japanese") - [한국어](https://ko.wikipedia.org/wiki/%EA%B8%80%EB%A1%9C%EB%B2%8C_%EC%9D%B8%ED%84%B0%ED%94%84%EB%A6%AC%ED%84%B0_%EB%9D%BD "글로벌 인터프리터 락 – Korean") - [Polski](https://pl.wikipedia.org/wiki/Global_Interpreter_Lock "Global Interpreter Lock – Polish") - [Русский](https://ru.wikipedia.org/wiki/%D0%93%D0%BB%D0%BE%D0%B1%D0%B0%D0%BB%D1%8C%D0%BD%D0%B0%D1%8F_%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D0%BE%D0%B2%D0%BA%D0%B0_%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%B5%D1%82%D0%B0%D1%82%D0%BE%D1%80%D0%B0 "Глобальная блокировка интерпретатора – Russian") - [Українська](https://uk.wikipedia.org/wiki/%D0%93%D0%BB%D0%BE%D0%B1%D0%B0%D0%BB%D1%8C%D0%BD%D0%B5_%D0%B1%D0%BB%D0%BE%D0%BA%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F_%D1%96%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%B5%D1%82%D0%B0%D1%82%D0%BE%D1%80%D0%B0 "Глобальне блокування інтерпретатора – Ukrainian") - [中文](https://zh.wikipedia.org/wiki/%E5%85%A8%E5%B1%80%E8%A7%A3%E9%87%8A%E5%99%A8%E9%94%81 "全局解释器锁 – Chinese") [Edit links](https://www.wikidata.org/wiki/Special:EntityPage/Q5570451#sitelinks-wikipedia "Edit interlanguage links") - [Article](https://en.wikipedia.org/wiki/Global_interpreter_lock "View the content page [c]") - [Talk](https://en.wikipedia.org/wiki/Talk:Global_interpreter_lock "Discuss improvements to the content page [t]") English - [Read](https://en.wikipedia.org/wiki/Global_interpreter_lock) - [Edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit "Edit this page [e]") - [View history](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=history "Past revisions of this page [h]") Tools Tools move to sidebar hide Actions - [Read](https://en.wikipedia.org/wiki/Global_interpreter_lock) - [Edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit "Edit this page [e]") - [View history](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=history) General - [What links here](https://en.wikipedia.org/wiki/Special:WhatLinksHere/Global_interpreter_lock "List of all English Wikipedia pages containing links to this page [j]") - [Related changes](https://en.wikipedia.org/wiki/Special:RecentChangesLinked/Global_interpreter_lock "Recent changes in pages linked from this page [k]") - [Upload file](https://en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard "Upload files [u]") - [Permanent link](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&oldid=1333191748 "Permanent link to this revision of this page") - [Page information](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=info "More information about this page") - [Cite this page](https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=Global_interpreter_lock&id=1333191748&wpFormIdentifier=titleform "Information on how to cite this page") - [Get shortened URL](https://en.wikipedia.org/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FGlobal_interpreter_lock) Print/export - [Download as PDF](https://en.wikipedia.org/w/index.php?title=Special:DownloadAsPdf&page=Global_interpreter_lock&action=show-download-screen "Download this page as a PDF file") - [Printable version](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&printable=yes "Printable version of this page [p]") In other projects - [Wikidata item](https://www.wikidata.org/wiki/Special:EntityPage/Q5570451 "Structured data on this page hosted by Wikidata [g]") Appearance move to sidebar hide From Wikipedia, the free encyclopedia Mechanism that ensures threads are not executed in parallel [![](https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/GIL_description.gif/250px-GIL_description.gif)](https://en.wikipedia.org/wiki/File:GIL_description.gif) Schematic representation of how threads work under GIL. Green - thread holding GIL, red - blocked threads A **global interpreter lock** (**GIL**) is a mechanism used in computer-language [interpreters](https://en.wikipedia.org/wiki/Interpreter_\(computing\) "Interpreter (computing)") to synchronize the execution of [threads](https://en.wikipedia.org/wiki/Threads_\(computer_science\) "Threads (computer science)") so that only one native thread (per process) can execute basic operations (such as [memory allocation](https://en.wikipedia.org/wiki/Memory_allocation "Memory allocation") and [reference counting](https://en.wikipedia.org/wiki/Reference_counting "Reference counting")) at a time.[\[1\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-1) As a general rule, an interpreter that uses GIL will see only one thread to execute at a time, even if it runs on a [multi-core processor](https://en.wikipedia.org/wiki/Multi-core_processor "Multi-core processor"), although some implementations provide for [CPU intensive](https://en.wikipedia.org/wiki/CPU-bound "CPU-bound") code to release the GIL, allowing multiple threads to use multiple cores. Some popular interpreters that have a GIL are [CPython](https://en.wikipedia.org/wiki/CPython "CPython") and [Ruby MRI](https://en.wikipedia.org/wiki/Ruby_MRI "Ruby MRI"). ## Technical background concepts \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=1 "Edit section: Technical background concepts")\] A global interpreter lock (GIL) is a [mutual-exclusion](https://en.wikipedia.org/wiki/Mutual_exclusion "Mutual exclusion") [lock](https://en.wikipedia.org/wiki/Lock_\(computer_science\) "Lock (computer science)") held by a [programming language](https://en.wikipedia.org/wiki/Programming_language "Programming language") [interpreter](https://en.wikipedia.org/wiki/Interpreter_\(computing\) "Interpreter (computing)") [thread](https://en.wikipedia.org/wiki/Thread_\(computer_science\) "Thread (computer science)") to avoid sharing code that is not [thread-safe](https://en.wikipedia.org/wiki/Thread-safe "Thread-safe") with other threads. In implementations with a GIL, there is always one GIL for each interpreter [process](https://en.wikipedia.org/wiki/Process_\(computing\) "Process (computing)"). Applications running on implementations with a GIL can be designed to use separate processes to achieve full parallelism, as each process has its own interpreter and in turn has its own GIL. Otherwise, the GIL can be a significant barrier to parallelism. ## Advantages \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=2 "Edit section: Advantages")\] Reasons for employing a global interpreter lock include: - increased speed of single-threaded programs (no necessity to acquire or release locks on all data structures separately), - easy integration of [C](https://en.wikipedia.org/wiki/C_\(programming_language\) "C (programming language)") libraries that usually are not thread-safe, - ease of implementation (having a single GIL is much simpler to implement than a lock-free interpreter or one using fine-grained locks). A way to get around a GIL is creating a separate interpreter per thread, which is too expensive with most languages.\[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed "Wikipedia:Citation needed")*\] ## Drawbacks \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=3 "Edit section: Drawbacks")\] Use of a global interpreter lock in a language effectively limits the amount of [parallelism](https://en.wikipedia.org/wiki/Parallel_computing "Parallel computing") reachable through [concurrency](https://en.wikipedia.org/wiki/Concurrency_\(computer_science\) "Concurrency (computer science)") of a single interpreter process with multiple threads. If the process is almost purely made up of interpreted code and does not make calls outside of the interpreter which block for long periods of time (allowing the GIL to be released by that thread while they process), there is likely to be very little increase in speed when running the process on a [multiprocessor](https://en.wikipedia.org/wiki/Multiprocessor "Multiprocessor") machine. Due to signaling with a CPU-bound thread, it can cause a significant slowdown, even on single processors.[\[2\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-2) More seriously, when the single native thread calls a blocking OS process (such as disk access), the entire process is blocked, even though other application threads may be waiting. ## Examples \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=4 "Edit section: Examples")\] Some language implementations that implement a global interpreter lock are [CPython](https://en.wikipedia.org/wiki/CPython "CPython"), the most widely-used implementation of [Python](https://en.wikipedia.org/wiki/Python_\(programming_language\) "Python (programming language)"),[\[3\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-3)[\[4\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-4) and [Ruby MRI](https://en.wikipedia.org/wiki/Ruby_MRI "Ruby MRI"), the [reference implementation](https://en.wikipedia.org/wiki/Reference_implementation "Reference implementation") of [Ruby](https://en.wikipedia.org/wiki/Ruby_\(programming_language\) "Ruby (programming language)") (where it is called Global VM Lock). [JVM](https://en.wikipedia.org/wiki/Java_virtual_machine "Java virtual machine")\-based equivalents of these languages ([Jython](https://en.wikipedia.org/wiki/Jython "Jython") and [JRuby](https://en.wikipedia.org/wiki/JRuby "JRuby")) do not use global interpreter locks. [IronPython](https://en.wikipedia.org/wiki/IronPython "IronPython") and [IronRuby](https://en.wikipedia.org/wiki/IronRuby "IronRuby") are implemented on top of [Microsoft](https://en.wikipedia.org/wiki/Microsoft "Microsoft")'s [Dynamic Language Runtime](https://en.wikipedia.org/wiki/Dynamic_Language_Runtime "Dynamic Language Runtime") and also avoid using a GIL.[\[5\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-5) An example of an interpreted language without a GIL is [Tcl](https://en.wikipedia.org/wiki/Tcl_\(programming_language\) "Tcl (programming language)"), which is used in the benchmarking tool [HammerDB](https://en.wikipedia.org/wiki/HammerDB "HammerDB").[\[6\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-6) ## Example code \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=5 "Edit section: Example code")\] Example code in [Python](https://en.wikipedia.org/wiki/Python_\(programming_language\) "Python (programming language)"). Notice how a lock is acquired and released between each instruction call. It uses the `Lock` object from the `threading` module.[\[7\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-7) ``` from threading import Lock INSTRUCTION_TABLE = { ... } def execute(bytecode: list) -> None: """Execute bytecode.""" lock = Lock() for (opcode, args) in bytecode: lock.acquire() INSTRUCTION_TABLE[opcode](args) lock.release() ``` ## Recent Development \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=6 "Edit section: Recent Development")\] **Free-Threaded Build (Python 3.13 and later)** In Python 3.13, an experimental "free-threaded" build of CPython was introduced as part of PEP 703 – *Making the Global Interpreter Lock Optional in CPython*. This build allows developers to compile Python without the Global Interpreter Lock (GIL), enabling true parallel execution of Python bytecode across multiple CPU cores. The feature is still experimental but represents a major step toward improved concurrency in future Python releases.[\[8\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-8) ## See also \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=7 "Edit section: See also")\] - [Green threads](https://en.wikipedia.org/wiki/Green_threads "Green threads") - [Giant lock](https://en.wikipedia.org/wiki/Giant_lock "Giant lock") ## References \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=8 "Edit section: References")\] 1. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-1)** ["GlobalInterpreterLock"](https://wiki.python.org/moin/GlobalInterpreterLock). *Python Wiki*. Retrieved 30 November 2015. 2. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-2)** [David Beazley](https://en.wikipedia.org/wiki/David_M._Beazley "David M. Beazley") (2009-06-11). ["Inside the Python GIL"](http://www.dabeaz.com/python/GIL.pdf) (PDF). Chicago: Chicago Python User Group. Retrieved 2009-10-07. 3. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-3)** Shannon -jj Behrens (2008-02-03). ["Concurrency and Python"](http://www.ddj.com/linux-open-source/206103078?pgno=2). [Dr. Dobb's Journal](https://en.wikipedia.org/wiki/Dr._Dobb%27s_Journal "Dr. Dobb's Journal"). p. 2. Retrieved 2008-07-12. "*The GIL is a lock that is used to protect all the critical sections in Python. Hence, even if you have multiple CPUs, only one thread may be doing "pythony" things at a time.*" 4. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-4)** ["Python/C API Reference Manual: Thread State and the Global Interpreter Lock"](https://web.archive.org/web/20080914102629/http://docs.python.org/api/threads.html). Archived from [the original](https://docs.python.org/api/threads.html) on 2008-09-14. Retrieved 2014-08-15. 5. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-5)** ["IronPython at python.org"](https://wiki.python.org/moin/IronPython). python.org. Retrieved 2011-04-04. "*IronPython has no GIL and multi-threaded code can use multi core processors.*" 6. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-6)** ["HammerDB Concepts and Architecture"](https://www.hammerdb.com/blog/uncategorized/hammerdb-concepts-and-architecture/). HammerDB. 2018-11-30. Retrieved 2020-05-10. "*It is important to understand at the outset that HammerDB is written in TCL because of the unique threading capabilities that TCL brings.*" 7. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-7)** ["threading — Thread-based parallelism"](https://docs.python.org/3/library/threading.html#lock-objects). *Python documentation*. Retrieved 16 April 2025. 8. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-8)** ["PEP 703 – Making the Global Interpreter Lock Optional in CPython \| peps.python.org"](https://peps.python.org/pep-0703/). *Python Enhancement Proposals (PEPs)*. Retrieved 2025-11-13. ![](https://en.wikipedia.org/wiki/Special:CentralAutoLogin/start?useformat=desktop&type=1x1&usesul3=1) Retrieved from "<https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&oldid=1333191748>" [Categories](https://en.wikipedia.org/wiki/Help:Category "Help:Category"): - [Python (programming language)](https://en.wikipedia.org/wiki/Category:Python_\(programming_language\) "Category:Python (programming language)") - [Concurrency control](https://en.wikipedia.org/wiki/Category:Concurrency_control "Category:Concurrency control") Hidden categories: - [Articles with short description](https://en.wikipedia.org/wiki/Category:Articles_with_short_description "Category:Articles with short description") - [Short description is different from Wikidata](https://en.wikipedia.org/wiki/Category:Short_description_is_different_from_Wikidata "Category:Short description is different from Wikidata") - [All articles with unsourced statements](https://en.wikipedia.org/wiki/Category:All_articles_with_unsourced_statements "Category:All articles with unsourced statements") - [Articles with unsourced statements from March 2023](https://en.wikipedia.org/wiki/Category:Articles_with_unsourced_statements_from_March_2023 "Category:Articles with unsourced statements from March 2023") - [Articles with example Python (programming language) code](https://en.wikipedia.org/wiki/Category:Articles_with_example_Python_\(programming_language\)_code "Category:Articles with example Python (programming language) code") - This page was last edited on 16 January 2026, at 07:10 (UTC). - Text is available under the [Creative Commons Attribution-ShareAlike 4.0 License](https://en.wikipedia.org/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License "Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License"); additional terms may apply. By using this site, you agree to the [Terms of Use](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use "foundation:Special:MyLanguage/Policy:Terms of Use") and [Privacy Policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy "foundation:Special:MyLanguage/Policy:Privacy policy"). Wikipedia® is a registered trademark of the [Wikimedia Foundation, Inc.](https://wikimediafoundation.org/), a non-profit organization. - [Privacy policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy) - [About Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:About) - [Disclaimers](https://en.wikipedia.org/wiki/Wikipedia:General_disclaimer) - [Contact Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Contact_us) - [Legal & safety contacts](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Legal:Wikimedia_Foundation_Legal_and_Safety_Contact_Information) - [Code of Conduct](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct) - [Developers](https://developer.wikimedia.org/) - [Statistics](https://stats.wikimedia.org/#/en.wikipedia.org) - [Cookie statement](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement) - [Mobile view](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&mobileaction=toggle_view_mobile) - [![Wikimedia Foundation](https://en.wikipedia.org/static/images/footer/wikimedia.svg)](https://www.wikimedia.org/) - [![Powered by MediaWiki](https://en.wikipedia.org/w/resources/assets/mediawiki_compact.svg)](https://www.mediawiki.org/) Search Toggle the table of contents Global interpreter lock 12 languages [Add topic](https://en.wikipedia.org/wiki/Global_interpreter_lock)
Readable Markdown
From Wikipedia, the free encyclopedia [![](https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/GIL_description.gif/250px-GIL_description.gif)](https://en.wikipedia.org/wiki/File:GIL_description.gif) Schematic representation of how threads work under GIL. Green - thread holding GIL, red - blocked threads A **global interpreter lock** (**GIL**) is a mechanism used in computer-language [interpreters](https://en.wikipedia.org/wiki/Interpreter_\(computing\) "Interpreter (computing)") to synchronize the execution of [threads](https://en.wikipedia.org/wiki/Threads_\(computer_science\) "Threads (computer science)") so that only one native thread (per process) can execute basic operations (such as [memory allocation](https://en.wikipedia.org/wiki/Memory_allocation "Memory allocation") and [reference counting](https://en.wikipedia.org/wiki/Reference_counting "Reference counting")) at a time.[\[1\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-1) As a general rule, an interpreter that uses GIL will see only one thread to execute at a time, even if it runs on a [multi-core processor](https://en.wikipedia.org/wiki/Multi-core_processor "Multi-core processor"), although some implementations provide for [CPU intensive](https://en.wikipedia.org/wiki/CPU-bound "CPU-bound") code to release the GIL, allowing multiple threads to use multiple cores. Some popular interpreters that have a GIL are [CPython](https://en.wikipedia.org/wiki/CPython "CPython") and [Ruby MRI](https://en.wikipedia.org/wiki/Ruby_MRI "Ruby MRI"). ## Technical background concepts \[[edit](https://en.wikipedia.org/w/index.php?title=Global_interpreter_lock&action=edit&section=1 "Edit section: Technical background concepts")\] A global interpreter lock (GIL) is a [mutual-exclusion](https://en.wikipedia.org/wiki/Mutual_exclusion "Mutual exclusion") [lock](https://en.wikipedia.org/wiki/Lock_\(computer_science\) "Lock (computer science)") held by a [programming language](https://en.wikipedia.org/wiki/Programming_language "Programming language") [interpreter](https://en.wikipedia.org/wiki/Interpreter_\(computing\) "Interpreter (computing)") [thread](https://en.wikipedia.org/wiki/Thread_\(computer_science\) "Thread (computer science)") to avoid sharing code that is not [thread-safe](https://en.wikipedia.org/wiki/Thread-safe "Thread-safe") with other threads. In implementations with a GIL, there is always one GIL for each interpreter [process](https://en.wikipedia.org/wiki/Process_\(computing\) "Process (computing)"). Applications running on implementations with a GIL can be designed to use separate processes to achieve full parallelism, as each process has its own interpreter and in turn has its own GIL. Otherwise, the GIL can be a significant barrier to parallelism. Reasons for employing a global interpreter lock include: - increased speed of single-threaded programs (no necessity to acquire or release locks on all data structures separately), - easy integration of [C](https://en.wikipedia.org/wiki/C_\(programming_language\) "C (programming language)") libraries that usually are not thread-safe, - ease of implementation (having a single GIL is much simpler to implement than a lock-free interpreter or one using fine-grained locks). A way to get around a GIL is creating a separate interpreter per thread, which is too expensive with most languages.\[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed "Wikipedia:Citation needed")*\] Use of a global interpreter lock in a language effectively limits the amount of [parallelism](https://en.wikipedia.org/wiki/Parallel_computing "Parallel computing") reachable through [concurrency](https://en.wikipedia.org/wiki/Concurrency_\(computer_science\) "Concurrency (computer science)") of a single interpreter process with multiple threads. If the process is almost purely made up of interpreted code and does not make calls outside of the interpreter which block for long periods of time (allowing the GIL to be released by that thread while they process), there is likely to be very little increase in speed when running the process on a [multiprocessor](https://en.wikipedia.org/wiki/Multiprocessor "Multiprocessor") machine. Due to signaling with a CPU-bound thread, it can cause a significant slowdown, even on single processors.[\[2\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-2) More seriously, when the single native thread calls a blocking OS process (such as disk access), the entire process is blocked, even though other application threads may be waiting. Some language implementations that implement a global interpreter lock are [CPython](https://en.wikipedia.org/wiki/CPython "CPython"), the most widely-used implementation of [Python](https://en.wikipedia.org/wiki/Python_\(programming_language\) "Python (programming language)"),[\[3\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-3)[\[4\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-4) and [Ruby MRI](https://en.wikipedia.org/wiki/Ruby_MRI "Ruby MRI"), the [reference implementation](https://en.wikipedia.org/wiki/Reference_implementation "Reference implementation") of [Ruby](https://en.wikipedia.org/wiki/Ruby_\(programming_language\) "Ruby (programming language)") (where it is called Global VM Lock). [JVM](https://en.wikipedia.org/wiki/Java_virtual_machine "Java virtual machine")\-based equivalents of these languages ([Jython](https://en.wikipedia.org/wiki/Jython "Jython") and [JRuby](https://en.wikipedia.org/wiki/JRuby "JRuby")) do not use global interpreter locks. [IronPython](https://en.wikipedia.org/wiki/IronPython "IronPython") and [IronRuby](https://en.wikipedia.org/wiki/IronRuby "IronRuby") are implemented on top of [Microsoft](https://en.wikipedia.org/wiki/Microsoft "Microsoft")'s [Dynamic Language Runtime](https://en.wikipedia.org/wiki/Dynamic_Language_Runtime "Dynamic Language Runtime") and also avoid using a GIL.[\[5\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-5) An example of an interpreted language without a GIL is [Tcl](https://en.wikipedia.org/wiki/Tcl_\(programming_language\) "Tcl (programming language)"), which is used in the benchmarking tool [HammerDB](https://en.wikipedia.org/wiki/HammerDB "HammerDB").[\[6\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-6) Example code in [Python](https://en.wikipedia.org/wiki/Python_\(programming_language\) "Python (programming language)"). Notice how a lock is acquired and released between each instruction call. It uses the Lock object from the threading module.[\[7\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-7) ``` from threading import Lock INSTRUCTION_TABLE = { ... } def execute(bytecode: list) -> None: """Execute bytecode.""" lock = Lock() for (opcode, args) in bytecode: lock.acquire() INSTRUCTION_TABLE[opcode](args) lock.release() ``` **Free-Threaded Build (Python 3.13 and later)** In Python 3.13, an experimental "free-threaded" build of CPython was introduced as part of PEP 703 – *Making the Global Interpreter Lock Optional in CPython*. This build allows developers to compile Python without the Global Interpreter Lock (GIL), enabling true parallel execution of Python bytecode across multiple CPU cores. The feature is still experimental but represents a major step toward improved concurrency in future Python releases.[\[8\]](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_note-8) - [Green threads](https://en.wikipedia.org/wiki/Green_threads "Green threads") - [Giant lock](https://en.wikipedia.org/wiki/Giant_lock "Giant lock") 1. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-1)** ["GlobalInterpreterLock"](https://wiki.python.org/moin/GlobalInterpreterLock). *Python Wiki*. Retrieved 30 November 2015. 2. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-2)** [David Beazley](https://en.wikipedia.org/wiki/David_M._Beazley "David M. Beazley") (2009-06-11). ["Inside the Python GIL"](http://www.dabeaz.com/python/GIL.pdf) (PDF). Chicago: Chicago Python User Group. Retrieved 2009-10-07. 3. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-3)** Shannon -jj Behrens (2008-02-03). ["Concurrency and Python"](http://www.ddj.com/linux-open-source/206103078?pgno=2). [Dr. Dobb's Journal](https://en.wikipedia.org/wiki/Dr._Dobb%27s_Journal "Dr. Dobb's Journal"). p. 2. Retrieved 2008-07-12. "*The GIL is a lock that is used to protect all the critical sections in Python. Hence, even if you have multiple CPUs, only one thread may be doing "pythony" things at a time.*" 4. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-4)** ["Python/C API Reference Manual: Thread State and the Global Interpreter Lock"](https://web.archive.org/web/20080914102629/http://docs.python.org/api/threads.html). Archived from [the original](https://docs.python.org/api/threads.html) on 2008-09-14. Retrieved 2014-08-15. 5. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-5)** ["IronPython at python.org"](https://wiki.python.org/moin/IronPython). python.org. Retrieved 2011-04-04. "*IronPython has no GIL and multi-threaded code can use multi core processors.*" 6. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-6)** ["HammerDB Concepts and Architecture"](https://www.hammerdb.com/blog/uncategorized/hammerdb-concepts-and-architecture/). HammerDB. 2018-11-30. Retrieved 2020-05-10. "*It is important to understand at the outset that HammerDB is written in TCL because of the unique threading capabilities that TCL brings.*" 7. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-7)** ["threading — Thread-based parallelism"](https://docs.python.org/3/library/threading.html#lock-objects). *Python documentation*. Retrieved 16 April 2025. 8. **[^](https://en.wikipedia.org/wiki/Global_interpreter_lock#cite_ref-8)** ["PEP 703 – Making the Global Interpreter Lock Optional in CPython \| peps.python.org"](https://peps.python.org/pep-0703/). *Python Enhancement Proposals (PEPs)*. Retrieved 2025-11-13.
Shard152 (laksa)
Root Hash17790707453426894952
Unparsed URLorg,wikipedia!en,/wiki/Global_interpreter_lock s443