From: Joel VanderWerf Date: 2005-07-22T04:57:45+09:00 Subject: Re: C extension makes things slower Joe Van Dyk wrote: > Wow, neat. Does Data_Get_Struct extract out members of a Ruby object > and assign them to corresponding members of a C struct? > No. Ruby instance vars are stored separately from the C struct belonging to a T_DATA object. In fact, in the case of T_DATA (and also T_ARRAY, T_PROC, etc.), instance variables are stored in a big global hash, indexed first by object id then by ivar name, IIRC. In the case of T_OBJECT (an instance of a normal user-defined ruby class) the ivars are stored ina hash in the object itself. When you allocate a T_DATA with the Data_Make_Struct (or Data_Wrap_Struct) macro, you also allocate (or pass in) a pointer to your own struct. The Data_Get_Struct macro, given a T_DATA, merely gives you back this pointer. The README.EXT in the ruby source covers this stuff if you want more detail.