[Pyrex] Pybsddb question

Brian Myers tarkawebfoot at charter.net
Thu Apr 13 04:48:12 CEST 2006


Yes, my code contains a:

cdef extern from "db.h":
     struct DB:
         pass
     struct DBT:
         int size
         int *data
     int set_bt_compare(DB *db, int (*bt_compare_fcn)(DB *db, DBT  
*dbt1, DBT *dbt2))

declaration. But I'm guessing by Greg's posting that I can't just get  
the underlying pointer and typecast it. Or at least I have to check  
with the pybsddb people before doing so.

Thanx

Brian

On Apr 12, 2006, at 7:37 PM, Greg Ewing wrote:

> tarkawebfoot at charter.net wrote:
>
>> I guess this isn't suprising since the __call__ function is called  
>> by Python. The parameters are going to be passed as Python  
>> objects. So the question is, how do I convert them to DBT objects?
>
> There's nothing called DBT defined in the code you
> posted. I'm guessing it's some C struct defined by
> bsddb, in which case whatever is making the Python
> call to your method must be passing it some kind
> of Python object that's wrapping a DBT.
>
> In that case, you'll have to consult the source
> of pybsddb and find out enough about that object
> type to declare it to Pyrex as an external
> extension type, and extract a DBT * from it.
> Read up about "External extension types"
> in the Language Overview:
>
> http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/ 
> extension_types.html#ExternalExtTypes
>
> -- 
> Greg Ewing, Computer Science Dept,  
> +--------------------------------------+
> University of Canterbury,	   | Carpe post meridiam!          	  |
> Christchurch, New Zealand	   | (I'm not a morning person.)          |
> greg.ewing at canterbury.ac.nz	    
> +--------------------------------------+



More information about the Pyrex mailing list