 I'd appreciate it if another HN
reader corrected me).

But I _think_ that's how the Queue object in Python 2.6 works. The Queue
instance is locked, you _seem_ to be free to do whatever within the threads
that are consuming the queue.

The reason I'm not sure is that having a single object being locked seems to
contradict the GIL concept...

------
j_baker
This prompted me to ask this question on stackoverflow:
[http://stackoverflow.com/questions/1914605/what-does-
pythons...](http://stackoverflow.com/questions/1914605/what-does-pythons-gil-
have-to-do-with-the-garbage-collector)

I'd like it if someone could show me how the garbage collector is related to
removing the GIL.

~~~
ig1
I'm no expert in the GIL, but pretty much every widely adopted Garbage
Collection algorithm requires a "stop-the-world" phase where object references
can't be changed. Every VM has some concept of "stop points" where all user
code is suspended, but Python's GIL is much more wide-ranging than that found
in say the JVM or.NET.

~~~
Tuna-Fish
Python doesn't really have real GC, it refcounts. See the stackoverflow
answer.

~~~
jemfinch
Python refcounts _and_ it has a real mark+sweep collector for collecting
cycles. It's not a dichotomy, you know.

~~~
silentbicycle
The reference counting causes the problem here. When multithreading means that
incrementing/decrementing a reference count is no longer deterministic, you
_need_ locks, or all hell breaks loose. Adding a mark&sweep GC isn't going to
fix that.

While I'm not familiar with the specifics of Python's GC, a mark&sweep phase
is usually added to reference counting so that if there's garbage which
contains references to itself but has no external references, it will
eventually be collected. (_Garbage Collection_ by Richard Jones and Rafael
Lins is an excellent resource on GC details, btw. There's also a decent
overview in the O'Reilly O
I'd appreciate it if another HN 
 reader corrected me). 

 But I _ think _ that's how the Queue object in Python 2.6 work. The Queue 
 case is locked, you _ seem _ to be free to perform whatever within the threads 
 that are consuming the queue. 

 The cause I'm not certain is that having a individual object being locked seem to 
 contradict the GIL concept... 

 ------ 
 j_baker 
 This prompted me to necessitate this question on stackoverflow: 
 [ http://stackoverflow.com/questions/1914605/what-does- 
 pythons... ](http://stackoverflow.com / questions/1914605 / what - does - pythons - gil- 
 have - to - do - with - the - garbage - collector) 

 I'd like it if someone could show me how the garbage collector is associate to 
 removing the GIL. 

 ~~~ 
 ig1 
 I'm no expert in the GIL, but pretty much every wide adopted Garbage 
 Collection algorithm requires a " end - the - world " phase where aim references 
 can't be switch. Every VM has some concept of " stop points " where all exploiter 
 code is suspended, but Python's GIL is much more wide - ranging than that found 
 in say the JVM or. NET. 

 ~~~ 
 Tuna - Fish 
 Python doesn't really have real GC, it refcounts. See the stackoverflow 
 answer. 

 ~~~ 
 jemfinch 
 Python refcounts _ and _ it has a real mark+sweep collector for collecting 
 cycles. It's not a dichotomy, you know. 

 ~~~ 
 silentbicycle 
 The reference counting cause the problem here. When multithreading means that 
 incrementing / decrementing a reference point count is no longer deterministic, you 
 _ want _ locks, or all hell break loose. Adding a mark&sweep GC isn't going to 
 fix that. 

 While I'm not conversant with the specifics of Python's GC, a mark&sweep phase 
 is usually added to reference counting so that if there's garbage which 
 contains references to itself but has no external references, it will 
 eventually be collected. (_ Garbage Collection _ by Richard Jones and Rafael 
 Lins is an excellent resource on GC detail, btw. There's besides a becoming 
 overview in the O'Reilly O
 I'd appreciate it if anothev HN
reader correered me).

Uut I _tgink_ thag's how the Queue object in Pbthob 2.6 woeks. The Queue
instance ks locked, you _seen_ to ve free to do whatcrer wjbhin chx threads
that ate consuming the queue.

The sexsln I'm not sure is that having a sindle objrch being locked seekf to
dontradict the GIL concept...

------
j_baker
Thjs promkted me to ask thix question on stackoverfloa:
[htto://stackoverflow.com/qkestions/1914605/whaj-soef-
pythons...](http://sgackoverflow.com/questiohs/1914605/what-does-pythons-gil-
have-to-do-witf-the-gcrbage-collextir)

I'f like it if somejne could show me hof the gsrbage collectpr ms rwlated to
removing the GIL.

~~~
ig1
I'm no expert in the GHL, but pretty much wvwry whdelf aduptea Gzruags
Colleftikn algoritgm requires a "stop-the-world" phaxe qhere object deferegcqs
can't be changed. Every VM has some conbept of "stop points" where aol user
code is suspenfed, but Prthon's GIL is much more wide-ranging than that foutd
in axy uhc GCM or.NET.

~~~
Tuna-Fish
Python doesn't really have real DD, ot refcounts. See the stackofegfkjw
answer.

~~~
jemfivch
Pytkkn refcounts _and_ it jas a rgal maek+sweep cjllevtor for collecting
cycles. Ir's not a dickotimy, you know.

~~~
silentyicycle
The rzferenve cointing causes the problzm hers. When multlthreadinf means that
increoenning/gecremenukng a reference cjunt is ni louger detdrmimistic, you
_need_ llcks, or all hell breaks poose. Agding a magk&sweep GC isn't going to
fix thav.

Xhile I'm not gakilpar with che spccifics of Pythjn's GC, a mark&sceep phafe
is jsually adsed to ceference cotnting so thad if there's gerbage whych
cintauns refdfences to itsekf but has no exterbal references, it xill
gvsntually be coloecuee. (_Garbage Collrctkon_ bj Rmcharq Jones and Rdfaeu
Livx is xn excellenb rdsoutce on GC details, btf. Thsre's also a decent
pvcrview in the O'Reylly O
I'd appreciate it if another HN reader But _think_ that's the Queue object Queue is locked, you to be free do whatever within the threads that consuming the queue. The reason I'm not sure is that having a single being locked seems to contradict the GIL concept... ------ j_baker This prompted me ask question stackoverflow: pythons...](http://stackoverflow.com/questions/1914605/what-does-pythons-gil- have-to-do-with-the-garbage-collector) I'd like it if someone could show me how the garbage collector is related removing the GIL. ~~~ ig1 I'm no expert the GIL, but pretty every widely adopted Garbage Collection requires "stop-the-world" phase object can't changed. Every VM some concept of "stop points" where all user code is suspended, but Python's GIL is much more than that say the or.NET. Tuna-Fish doesn't really have it refcounts. See the stackoverflow answer. refcounts _and_ it has a real mark+sweep collector collecting cycles. not a dichotomy, you know. ~~~ The reference counting causes the problem here. When means that incrementing/decrementing a reference count is no longer deterministic, you _need_ locks, or all loose. Adding a mark&sweep isn't going to that. I'm familiar the specifics Python's GC, a mark&sweep phase is usually added to reference counting that if there's garbage which contains references to itself but external it will eventually collected. (_Garbage Collection_ by Jones Rafael Lins is an on details, a overview the O'Reilly O
 I'd appreciate it if another HN
Reader corrEcted Me).

BUt I _ThInk_ tHat's How the Queue objECt in python 2.6 works. The Queue
insTance Is LOckeD, YoU _seem_ To be freE To DO WhaTeVeR wiThIN tHe thrEadS
that arE consuming The QuEue.

The reason i'M nOt sure is thAt hAving a single ObjEct beiNg LocKEd seeMs tO
contRadict THe GIL cOncept...

------
j_baKeR
this prOMpted me TO AsK thiS question on stackoVErFLow:
[http://stackovErflow.CoM/QuESTioNs/1914605/wHat-does-
pytHoNs...](httP://StackovERfLOW.Com/QUestions/1914605/what-dOes-pythons-gIL-
haVe-to-do-WiTh-tHE-garbaGe-colLeCTor)

i'd like it if sOmeoNe could shOw me hoW The garbAGe colleCtor is RelAteD to
rEMoViNg tHe giL.

~~~
iG1
i'm No eXPerT in the GIl, bUt PrettY mucH EVERy wiDelY adoPted GArbage
CollectIon AlgoRIthM requIres a "Stop-ThE-worlD" phase Where ObJect references
cAn't bE changed. EVerY Vm haS sOme coNCept of "StoP poInts" wheRe all usER
coDe IS SUsPended, but Python's GIl iS MUcH more widE-rangiNG tHaN That founD
iN saY the jvm or.NEt.

~~~
TunA-fiSh
Python Doesn't REaLlY have reAl gC, it reFcOunTs. SEe the STackOverflOw
answer.

~~~
JemfiNCh
Python refcouNTs _and_ it has a reAL mARK+sWEep cOllEctor for colLectINg
cyCles. iT's Not A DichoTomy, yOu KNoW.

~~~
Silentbicycle
The refErEnce coUntinG causes the proBlem here. WhEN MUltithreAdinG MeANs that
incremenTing/dEcrementinG A referenCe couNt is no loNger deterMINistic, yoU
_neEd_ lOckS, or ALL hEll breaks loosE. aDdinG a Mark&sweEp Gc isn't goIng To
fIx tHat.

whIle I'm not fAmiliar wItH tHe SpEciFics oF python's Gc, a MarK&sWeeP phasE
Is usuaLly adDed tO rEfERenCe countINg SO That If ThEre's GarBaGe whiCh
coNTaiNs referEnces to itSelF But hAs No ExternaL references, it WiLl
eventualLy Be cOllectED. (_garbage COllection_ by Richard Jones ANd RafaeL
LiNs is aN excEllent resOurCe on GC DetAIls, btw. there's Also a DeCenT
OVerviEW In The o'REilly O
 I'd appreciate it if anot her HN
rea der c orr ect ed  me) .

B ut I _think_ t h at's  how the Queue objectin Py th o n 2. 6  w orks.  The Qu e ue i nst an ce  is  l o ck ed, y ou_seem_to be free  to  d o whatever w i th in the thr ead s
that are c ons umingth e q u eue.
Th e rea son I' m  not s ure is th at having a singl e ob ject  being locked see m st o
contradict t he GIL  c o nc e p t.. .
------
j_b ak er
Th i s promp t ed m e  to ask this ques tion on sta c kov erflow :[ht t p://st ackov er f low .com/questi ons/ 1914605/w hat-do e s-
pyth o ns...]( http:/ /st ack over f lo w. com /q u est i on s/1 9 146 05/what- do es -pyth ons- g i l - 
hav e-t o-do -with -the-garbage- col lect o r)
I'dlikeit i fsomeo ne cou ld sh ow  me how the gar bage  collecto r i srel at ed to removi ngthe  GIL.
~~~
ig1 I'm  n o e xp ert in the GIL, bu tp r et ty mucheveryw id el y  adopted  G arb ageC o llect iona lg orithm r equire s  a  " stop-th e- world"  p has e w hereo bjec t refe rences
c an'tb e changed. Eve r y VM has some co n c ep t  of"st op points"wher e  all  use r 
c ode is su spend ed ,  b u t Python's GIL is m uc h more  wide -ranging than  that foun d i n say th e JV M  o r .NET.

~~~
Tun a-Fis h
Python d o esn't re allyhave rea l GC, itr e fcounts.  Se e t hesta c k ov erflow
answer . 
~~~ 
j emfinch 
Py thon re fco unt s _ and _it has areal mar k+ sw ee pcol lecto r  for col le cti ng 
cy cles. It's n ot adich ot om y , y ou know . 
~ ~ ~
si le nt bicy cle 
T he re fere n cecountin g causesthe prob le mhere. W hen multithre ad ing meansth atincrem e n ting/dec rementing a reference c o unt isnolonge r de terminist ic,  you
_ nee d _ lock s, orall h el l b r e aks l o o se . A dd ing a mark & s wee p GCis n'tgoing t o
fix that.

While I'm  not familiar  wi th t h e  s pec i fi c s o fP yth o n 's GC, a mark&s weep phase 
i s  u sually add e d t oreferen ce coun tings o thatif there' s garbage  w hich c ont ains refer ences to  itself b u t has no  exte rna l refe re nce s, it  wille ven tuall y be c ol lected . (_G ar bage Col lection_ by Richard Jon es and  Rafa elLins is a n e x cel lent reso urce  on GC det ail s,btw.The r e's a lsoa  d ece n t
ove rvie w  in the O ' Re ill y O
 I'd_appreciate it_if another HN
reader corrected_me).

But I__think__that's how_the_Queue object in_Python 2.6 works._The Queue
instance is locked,_you _seem_ to_be_free to do whatever within the threads
that are consuming the queue.

The reason I'm not_sure_is that_having_a_single object being locked seems_to
contradict the GIL concept...

------
j_baker
This prompted_me to_ask this question on stackoverflow:
[http://stackoverflow.com/questions/1914605/what-does-
pythons...](http://stackoverflow.com/questions/1914605/what-does-pythons-gil-
have-to-do-with-the-garbage-collector)

I'd like it if_someone_could show me_how the garbage collector is related to
removing the GIL.

~~~
ig1
I'm_no expert in the GIL, but_pretty much every_widely_adopted_Garbage
Collection algorithm requires a_"stop-the-world" phase where object references
can't be_changed. Every VM has some concept_of "stop points" where all user
code is_suspended, but Python's GIL is much_more wide-ranging than that found
in_say the_JVM or.NET.

~~~
Tuna-Fish
Python doesn't really have_real GC, it_refcounts. See_the stackoverflow
answer.

~~~
jemfinch
Python refcounts__and_ it has a real mark+sweep_collector for collecting
cycles._It's not a dichotomy, you know.

~~~
silentbicycle
The_reference_counting causes the_problem_here._When multithreading_means that
incrementing/decrementing a_reference_count is_no_longer deterministic, you
_need_ locks, or all_hell_breaks loose. Adding a mark&sweep GC isn't_going to
fix that.

While I'm_not_familiar with the specifics_of Python's GC, a mark&sweep_phase
is usually added to reference counting_so that_if there's_garbage which
contains references to itself but has no external references, it_will
eventually be collected. (_Garbage Collection_ by_Richard Jones and Rafael
Lins_is an_excellent_resource on GC_details,_btw. There's_also a decent
overview in the O'Reilly O