[Bf-python] Minimalist "set" built-in type for blender w/Python 2.3?

Ken Hughes khughes at pacific.edu
Wed May 24 19:49:41 CEST 2006


Ken Hughes wrote:
> I started looking over old code I'd worked on which added tp_getset 
> access to sceneRender.c, and in the process it reminded me of something 
> else which I wanted to do.  I'm cringing each time I add something new 
> to the API which uses bitmask/bitfields, knowing we don't want to do it 
> this way in the new API.
> 
> We'd discussed using the set built-in which was added to in Python 2.4, 
> but since we need to still be backward compatible with 2.3 I was 
> thinking about implementing a minimalist set built-in type which would 
> only be compiled into Blender running Python 2.3 (which Stephen also 
> tells me should only be needed on Windows since it's assumed all other 
> OSes have python installed).
> 
> I figure it's either write this now and then implement access to 
> bitfields right now (and throw this built-in away when we scrap 2.3), or 
>  go back and have to re-write the access in the new modules later along 
> with everything else.  So in my mind, it would be less work to do this 
> in the long run.
> 
> If anyone thinks this is a really bad idea, then tell me now before I 
> spend time trying to do it.  If anyone thinks it's a really good idea, 
> then also tell me now so I can get started.
> 
> If this seems like a good idea, what methods and operators must be 
> supported?  Remember, the intent is to allow manipulation/access to 
> Blender bitfields, not for general-purpose usage.

OK, a summary from discussion on IRC this morning with Stephen, Joseph, 
Toni and others:

* Using sets would require a BPy wrapper of sorts, so that input could 
be checked and changes reflected in the Blender data without having to 
assign the data or do something like .update().  Basically, we would 
need to implement our own set-like built-in datatype.
* Some users would like boolean access to individual settings through 
attributes in addition to access through the bitfield.  So statements 
like "curve.cyclic = True" to control individual setting without having 
to know which bitfield to modify.  But other users would like to be able 
to set/clear all settings at once, either through bitfields or sets.
* Bitfields are difficult for some script writers to comprehend (for 
lack of a better word).  They are uncomfortable or unfamiliar with using 
| and & to manipulate bitfields.  However, they would almost certainly 
execute faster than a set-like type, but since the statements are not 
going to be executed frequently this is probably not a big issue.

Bottom line: seems like no consensus for what to do at this point.

Ken







More information about the Bf-python mailing list