[Bf-python] Const dict arguments

Stephen Swaney sswaney at centurytel.net
Wed Jul 20 17:27:41 CEST 2005


On Wed, Jul 20, 2005 at 07:06:39AM -0700, Ken Hughes wrote:
> 
> Ok, so should all the existing x.getStuff()/x.setStuff() use the 
> tp_getset and we ignore const dicts for now, and fix the mixture of 
> const dicts, strings, lists, units, etc., in a later pass through the 
> code?  Or should all the new tp_getset methods use const dicts, meaning 
> that some of the existing x.getStuff()/x.setStuff() methods will not 
> just call the appropriate method from the PyGetSetDef table (the one for 
> the tp_getset slot) if they don't use const dicts?

At the moment, we have not defined the whats and wheres of how the
cleaned up API will look.  Also, if we are going to make drastic
changes, it is better to do it all at once.

So, for our first pass thru the code, we want to install the tp_getset
methods and tables and replace our existing 'stringy' attribute
access.  We do *not* want to change anything visible in the API yet.
That comes later.

The big question is what to do about the x.setStuff() methods.
Possibilities are

1) simply duplicate the code and change arguments and return types for
tp_getset.

2) change the x.setStuff() methods to call into the new tp_getset
methods.

3) implement the new tp_getset code as wrappers calling the old
x.setStuff() methods.

Personally, I prefer 2) for the following reasons:

  When we are done with this clean up phase, I would expect that not
  all the methods will have new argument types.  Lots of reuse!

  I would like to hang on to the old x.setStuff() interface for
  backwards compatibliity as long as we can.  It should fade away over
  time, however.  This is all negotiable, of course.

  Choice 3) leaves us with bloated code with a lot of unnecessary arg
  parsing and passing and leaves us in a position of supporting stuff
  we want to go away

The Recommend Plan in a Nutshell:

  Add the new tables and definitions for the tp_getset slot.

  Create the tp_getset methods by cutting the code from the old
  attribute getters and setters.

  Fix up the old x.setStuff() / x.getStuff() methods as wrappers for
  the tp_getset methods.

  While all of the above is going in, we can discuss where and how we
  need to make changes for the updated, cleaner tp_getset API.

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list