>I wrote two versions of the dict views refactoring. One that turns
>d.keys() into list(d.keys()) and d.iterkeys() into iter(d.keys()).
>This one is pretty robust except if you have classes that emulate
>2.x-style dicts. But it generates ugly code. So I have a
>"light-weight" version that leaves d.keys() alone, while turning
>d.iterkeys() into d.keys(). This generates prettier code but more
>buggy. I probably should have used the heavy-duty one instead.
The ugliness is a virtue in this case as it stands out enough to motivate
developers to review each case. The pretty/efficient version is tantamount
to guessing, and effectively discards information in the transformation
("here be dragons").
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com