Python and Boehm-Demers GC, I have code.
Tim Peters
tim_one at email.msn.com
Sat Jul 17 03:13:05 EDT 1999
More information about the Python-list mailing list
Sat Jul 17 03:13:05 EDT 1999
- Previous message (by thread): Python and Boehm-Demers GC, I have code.
- Next message (by thread): Python and Boehm-Demers GC, I have code.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Tim] > ... Did the "collection" phase of BDW find any trash at all? [Neil Schemenauer] > It doesn't unless you create some. The patch creates a version > of Python that uses GC only to clean up reference cycles. Just as it appeared <wink>. So it's really no surprise that the overall timing didn't change much in pybench, right? > ... > BTW, _tkinter is not working perfectly yet. I think lambdas > passed as callbacks are getting collected. Such as to key bindings? Harmonic convergence (I was just looking at that in IDLE tonight!). When you pass a lambda (or bound method object, or any callable object -- CO for short) as a binding, Tkinter.py eventually wraps the CO in an instance of Tkinter.CallWrapper, and the .__call__() method of that instance is passed on to _tkinter.c's Tkapp_CreateCommand via Tkinter.Misc._register(). The interesting thing here is that nothing in Tkinter.py holds on to anything from which the CO can be reached. Instead _tkinter.c's Tkapp_CreateCommand bumps the CO's refcount, stuffs a pointer to the CO in a heap-allocated new instance of a PythonCmd_ClientData struct, and passes a pointer to the latter on to Tcl via Tcl_CreateCommand. _tkinter.c doesn't hold on to a reference to this either: when Tkapp_CreateCommand returns, Tcl the sole owner of the CO reference that was added, and Tcl is the only one who knows the address of the PythonCmd_ClientData struct. So if the CO is an embedded lambda expression, there is only one reference to it in total, and only Tcl can reach it (which it does when the binding triggers, and then it passes a pointer to the PythonCmd_ClientData struct back to _tkinter.c's PythonCmd). So if BDW isn't crawling over Tcl/Tk's memory too, the lambda will look like trash, and the PythonCmd_ClientData struct will look like trash regardless of what flavor of CO was passed. So BDW has to get at Tcl's memory too, or _tkinter.c has to maintain a list of allocated PythonCmd_ClientData thingies (until PythonCmdDelete is called back from Tcl), or ... It's convoluted for sure, but I do expect you'll find "the answer" at the bottom of it. rc-is-so-simple<wink>-ly y'rs - tim
- Previous message (by thread): Python and Boehm-Demers GC, I have code.
- Next message (by thread): Python and Boehm-Demers GC, I have code.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list