Hi --

On Sun, 13 Aug 2006, Thies C.  Arntzen wrote:

> Brian McCallister schrieb:
>
>> How difficult would it be to do an OrderedHash data structure as a C
>> extension instead of in Ruby?
>
> i really believe that it needs to be a 1st class citizen - the reason
> it's done in C is because userland imposes too much overhead (i
> believe) and converting forward<->back to the normal Hash would be
> slow, memory intensive and ordering information would get lost on the
> way...
>
> also the amount of code added to the Hash class is ~20 lines of C-code
> - this code adds zero overhead. the bigger chunk of the code was added
> to the st.c which is the underlying library for handling hash-tables -
> and duplicating > 600 lines of code to add ~60 lines didn't seem very
> cool to me;-)

The problem you likely face, though, is that no one will use it (which
may or may not matter to you :-)  You're requiring that people use a
patched Ruby, and if anyone writes an application that uses it, then
they require that everyone who runs the application use a patched
Ruby, and so on.

It's much more likely -- probably literally thousands of times more
likely -- that people will try out something distributed as an
extension than that they'll patch the Ruby source.  And C extensions
are very fast, once loaded.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.