From: Steven Jenkins Date: 2005-04-05T03:21:52+09:00 Subject: Re: Extension question Joe Van Dyk wrote: > And to expand the question... > > I'm using the GD library to create the image. I'm creating the image > by reading binary data from a file and looping through some > predetermined width and height and setting each pixel of the picture > based on the data from the file. > > Which parts of this should go in the C extension and which parts > should stay Ruby? I'm really scratching my head over this one. If you're writing the extension to solve a performance problem, then I recommend the general approach of putting in the extension *only* what is required to solve the performance problem. If your Ruby code doesn't need to do anything with the file itself, I'd just hand the filename to the extension and let it open/read/write/close, whatever. Alternately, you could ope the file in Ruby and use IO#fileno to pass the open file descriptor to the extension. Then you could operate on that fd with read()/write()/etc. Doing actual IO in both Ruby and the extension may require care. Steve