Cover photo
Michael Foord
Works at Canonical Ltd.
Lives in Northampton UK
4,279 followers|525,245 views


Michael Foord

Shared publicly  - 
I recently visited the Guggenheim museum in Bilbao and got embroiled in a conversation on the value of art, and in particular the value of modern art. This is an age old question, and more specifically this question: does art...
Radomir Dopieralski (deshipu)'s profile photo
I'm afraid that if you really did such a test, then you would get the most response from common porn, followed by scenes of violence and gore -- because our brains are hardwired to pay attention to that. I think the quality of experience is much more important here than quantity. But of course, how do you measure the quality?
Add a comment...

Michael Foord

Shared publicly  - 
A short blog entry wherein I reveal the [not so very] secret of spiritual power.
Add a comment...

Michael Foord

Shared publicly  - 
At EuroPython I spend a bit of time talking to +Larry Hastings about reference counting, garbage collection and free threading (the Global Interpreter Lock) in Python.

Larry also gave a (very good) talk on the GIL, and the barriers to removing it in current CPython.

The problem of course is reference counting, which is inherently thread unsafe. Adding locking to reference counting gives a performance hit to single threaded code of about 30%.

A "better" approach would be to move CPython away from reference counting to a more modern garbage collection scheme (something like a generational collector). The difficulty is that existing C extensions would be incompatible with this new CPython as C extension objects would be opaque to the new collector until they're modified (so the new collector is able to find references they hold to other objects). So you would break compatibility with every existing C extension.

The experience of pypy shows that breaking compatibility with C extensions is a deal breaker for many people, and it's a very hard road to substantial adoption with that barrier in place.

Larry's conclusion is that the performance hit for single threaded code (locking around the reference count) is probably the only viable option if we want free threading in CPython.

I worked for a while at a company called Resolver Systems building a spreadsheet application in IronPython. A lot of people wanted to use numpy in their spreadsheets, but IronPython didn't have the Python C API - so numpy didn't work (and a lot of other Python code that relied on C extensions). We (well, mostly +William Reade) implemented something called IronClad. A combination of C#, IronPython, C and assembly code that implemented the Python C API for IronPython. It had binary compatibility with compiled windows extensions (existing C extensions didn't need to be recompiled to work with IronClad). Quite an amazing, and terrifying, piece of engineering.

Because it worked with IronPython, built on .NET, it needed to work without a GIL and with the generational collector. We just pretended that the GIL not being there wasn't a problem (the acquire and release GIL C API methods were empty stubs). This never was a problem for us. For C extensions to still be able to use reference counting, and .NET garbage collection to also work, we needed a hybrid approach.

I've sketched out a potential hybrid approach for CPython that would (if it is sound) allow CPython to move to a more modern garbage collection scheme whilst remaining compatible with C extensions that haven't been updated to be compatible with the new collector. It would require extensions to be recompiled, so it breaks ABI compatibility.

Objects that don't support "new garbage collection" (ngc) are opaque to the garbage collector, they are considered to hold no references which are then tracked externally. So reference counting becomes slower (!), but it's only "old" extensions that are using it.

The reference count field remains for all objects, but is unused by normal Python objects.

Access to the ref count field is protected by a lock to be thread safe.

IncRef and DecRef macros become very different (but are, again, not used by standard objects).

Objects incompatible with "new garbage collection" need a new field. This is the tricky bit if it's to be done without requiring the objects to change - the field might need to be created and tracked by the interpreter rather than the extension. (That's the first hand-wavy bit.) The field is a "reference pool", a list of weak references to objects referenced by the opaque object.

When incrementing a reference count, if the count goes from zero to one a reference is also added to a global pool. This keeps the object safe from "normal garbage collection". A new weak ref to the object referenced is  added to the reference pool for the referer. (This is the really tricky bit IncRef needs to know which object is doing the incrementing. So effectively IncRef needs to become an instance method. IronClad didn't have this problem because it only ever used "shadow objects" - a kind of proxy to the real Python object because IronPython objects have a very different memory layout to the one that Python C extensions expect - so we only needed to track the reference count on the shadow objects.)

When decrementing a reference count, if the count drops to zero  the reference from the global pool is removed, once again making the object available for normal collection.

When an opaque object is collected by ngc, all the objects held in the "reference pool" for that object need to have their reference count decremented.

So, performance for reference counting extensions will be worse until those extensions are updated to support ngc - but the hybrid system should work.

Another issue is probably that a moving collector would also be incompatible with C extensions that use direct memory access (possible for things like lists). We had that problem theoretically in IronClad but never had any actual problems due to this. Well behaved C code ought to be going through API methods to access members rather than direct memory access anyway.
Ryan Smith-Roberts's profile photoSarah Mount's profile photo
Possibly, but maybe python-ideas. These are not things that I have implemented in CPython, just ideas from the literature, so someone would need to benchmark them.
Add a comment...

Michael Foord

Shared publicly  - 
Watchman Nee described humans as "tripartite", consisting of spirit, soul and body. This is a particular framing of the human condition, a way of thinking about and understanding ourselves. There are many other alternative (o...
Add a comment...

Michael Foord

Shared publicly  - 
There has been a lot of exploration and rediscovery of God as father in my church recently. I've had my own experience of this and, as the cliche goes, it came through observing my own children. A few days ago I was at the de...
Add a comment...

Michael Foord

Shared publicly  - 
It's been a long time since I've posted. Inspiration comes and goes in waves, and mostly I feel like I've written a fair amount in the last year and it's time to prove it rather than speaking more. In the meantime I occasiona...
Add a comment...

Michael Foord

Shared publicly  - 
On how we believe (and by implication why most theology is useless).
Add a comment...

Michael Foord

Shared publicly  - 
Add a comment...

Michael Foord

Shared publicly  - 
At EuroPython this year myself and my colleague +Dimiter Naydenov spoke about deploying to the cloud, and why you should do it even if you don't want to.

It's about devops and the awesome devops tool we work on, Juju. To the clouds:
Eric Hanchrow's profile photoDr. Computers's profile photo
olá bom dia, vc poderia me ajudar com isso por favor ???
tenho 3 checbox and 1 button , ao clicar no botão executa o programa selecionado no checkbox ???
segue meu código :

import wx, os, sys

class executa(wx.Frame):
    def _init_(self, *args, **kw):
        super(executa, self).__init__(*args, **kw) 
    def InitUI(self):   

        pnl = wx.Panel(self)
        cb1 = wx.CheckBox(pnl, label='CALCULADORA', pos=(15, 50))
        cb2 = wx.CheckBox(pnl, label='BLOCO DE NOTAS', pos=(15, 70))
        cb3 = wx.CheckBox(pnl, label='PAINT BRUSH', pos=(15, 90))
        btn = wx.Button(pnl, label='ABRIR', pos=(80, 150), size=(60, -1))

        btn.Bind(wx.EVT_BUTTON, self.check_value)

        self.SetSize((400, 300))
        self.SetTitle('abre programa selecionado')
    def check_value(self, e):
        if cb1.isChecked():
         os.system("start /wait calc.exe")
        if cb2.isChecked(): 
         os.system("start /wait NOTEPAD.exe")
        if cb3.isChecked():    
         os.system("start /wait PBRUSH.exe")
        else :
def main():
    ex = wx.App()

if _name_ == '__main__':
 ·  Translate
Add a comment...
Michael Foord has been programming with Python since 2002. For several years Michael developed full-time with IronPython, becoming the first Microsoft MVP for dynamic languages, and the author of "IronPython in Action" for Manning Publications. 

Michael now works for Canonical, doing web development with Django.

Michael is also a PSF member and a core Python developer, maintaining the standard-library testing framework unittest.

Michael writes and blogs about Python far more than is healthy, and in the real world lives in Northampton, UK, with his wife Delia.
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Northampton UK
Software Engineer
  • Canonical Ltd.
    Software Engineer, 2010 - present
    Software Engineer, 2009 - 2010
  • Resolver Systems
    Senior Software Engineer, 2006 - 2010
Basic Information
Michael Foord's +1's are the things they like, agree with, or want to recommend.
When the Music Starts

WHEN THE MUSIC STARTS 1 Captain's Log, Stardate: Tuesday 22 nd December 1970 Sheffield City Hall 8.30 pm -Band begins extended interstellar

You are a cockroach

This post is a confusing one for me to write. In this, I discuss my confusion at referring to humans as cockroaches. I draw from a rapper ca

I read Your Theology Book

I read your theology book It said lots of things about God and people and Jesus. The writing was all joined up,connected By neat straight li

God does not attend the theatre

God does not attend the theatre, But he will come to your house, Mad house,whore house, Sad house,poor house, Bad house-your house. Even if


Python is a remarkably powerful dynamic programming language.

Python 3 Resources for Python developers and users. On second thought, let's not go to Camelot. It is a silly place. Monty Python and th

YouTube - LEGO Star Wars Sith Nightspeeder - 7957

Create AccountSign In. Home. BrowseMoviesUpload. Hey there, this is not a commercial interruption. You're using an outdated browser, whi

BTGuard Review | BTGuard Reviews | Hide IP Tools Reviews

Initial check of new torrents and acqusition of seeds is a bit slower than normal, but afterwards the transfer speeds match watch I was gett

This is the countdown.

A whole new world. A whole new computer.

Steven Seagal DVD Collection | Flog the Dogs

Exit Wounds; Under Siege; Under Siege 2; Executive Decision; Nico (Above the Law); Fire Down Below; Out for Justice; The Glimmer Man. Costs

Ubuntu TV

TV for Human Beings

Iraq Album

A few old pics from Iraq showing...well, you can see for yourself.. Photo above is taken in back of armoured car. Same car, 24 hrs later: Br

Local Classified Ads | Flog the Dogs

Local Ads For Local People. Flog the Dogs is free to use! Flog the Dogs is a local classified ads website, for selling or giving away second

Troy Hunt: Lessons in website security anti-patterns by Tesco

Troy Hunt on observations, musings and conjecture about the world of software and technology

SIM Card Deals |

With a giffgaff SIM Card you'll get 250 minutes, unlimited texts and unlimited mobile Internet for only £10 with giffgaff.

Forcing web API consumers to be robust |

I have a web API that returns object attributes as JSON, i.e. name=value pairs. We're discovering that adding new fields breaks a lot of

Invention of Colour

New graphic t-shirts released weekly. Awesome new designs submitted and rated by the Threadless community.

Node.js Is Bad Ass Rock Star Tech

A Q&A session on web servers turns existential.

I Voted for New Zealand Lamb Shanks from Westin Gourmet!

Vote for you favourite at, or why not try the Lamb Shanks for yourself

xkcd: Wisdom of the Ancients

Permanent link to this comic: Image URL (for hotlinking/embedding):

I started as a complete beginner three months ago and I'm really enjoying it. Krav Maga is helping me with fitness, body awareness and confidence. The lessons are completely practical, the group is friendly and James is an *excellent* instructor. I found it very approachable as a complete beginner and after a few months I think I've progressed as far as "mostly a beginner". :-) The focus is very much on defence and awareness: how to get out of difficult situations and defend yourself. The lessons (1 1/2 hours) are very energetic and physical, so perhaps not ideal if you're *only* interested in getting fit. If you're interested in learning useful self-defence techniques, and are willing to throw yourself into it, you'll have a great time.
• • •
Public - 2 years ago
reviewed 2 years ago
The food is mediocre to good, produced quickly in great quantities. The counterbalance is that there is a great variety of food and it's an all you can eat buffet.
Food: GoodDecor: GoodService: Good
Public - 3 years ago
reviewed 3 years ago
2 reviews