From: "Shot (Piotr Szotkowski)" Date: 2009-12-20T08:51:16+09:00 Subject: Re: [ANN] google_hash 0.1.1 -- it has a #each! --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Roger Pack: > Shot wrote: >> I have a big need for a fast Set of integers/bignums > You just need fast iteration? Fast insertion? Iteration, mostly. Na=C3=AFve profiling of my Set-heavy code says it spends most of the time in Hash#each_key (as a result of calls to Set#each). > The google hash lib itself has both Hashes and Sets--I just have > focused on the Hash stuff as of yet, but hope to do them all (with > more types) eventually. Ah, perfect. I=E2=80=99ll definitely take a look (at both your gem and Google=E2=80=99s variants). > With just int (or double) you could reasonably > easily store your keys and/oor values as native. Yeah; unfortunately, in most cases (definitely in the slow ones) I need Bignum support; I=E2=80=99m storing sets of (usually large) integers as turned-on Bignums=E2=80=99 bits. > With Bignum I'm not totally sure how they're stored in memory, > but with some hacking it is probably possible to "store them away" > (i.e. store a copy of them on entry so that Ruby is no longer memory > tracking them). One of the routes I can take is writing my own IntSet class in (possibly inline) C or D, but I=E2=80=99d rather prototype it in Ruby first, and rewr= ite only if necessary. It seems I should at least try to make it use the Google=E2=80=99s hash/set implementation. > What would the ideal be in terms of requirements? Hm, I guess I should implement and profile the skelatal IntSet first to be sure, but something with fast #each and #combination(2) calls would already make wonders in my case (Set#each calls Hash#each_key, while my current Set#pairs implementation consists of calling to_a.combination(2), so probably there=E2=80=99s a lot of space for improve= ment already right there). BTW =E2=80=93 I=E2=80=99m not sure why, but got the below under both 1.8.7p202 and 1.9.1p376 (both 64-bit): shot@devielle:~$ gem install google_hash ERROR: Error installing google_hash: sane requires os (>=3D 0, runtime) shot@devielle:~$ gem install sane ERROR: Error installing sane: sane requires os (>=3D 0, runtime) shot@devielle:~$ gem install os Successfully installed os-0.3.0 1 gem installed Installing ri documentation for os-0.3.0... Installing RDoc documentation for os-0.3.0... shot@devielle:~$ gem install google_hash Building native extensions. This could take a while... Successfully installed sane-0.16.0 Successfully installed google_hash-0.1.1 2 gems installed Installing ri documentation for sane-0.16.0... Installing ri documentation for google_hash-0.1.1... Updating class cache with 2317 classes... Installing RDoc documentation for sane-0.16.0... Installing RDoc documentation for google_hash-0.1.1... shot@devielle:~$=20 =E2=80=94 Shot --=20 Deleted code is debugged code. [Jeff Sickel] --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkstZnIACgkQi/mCfdEo8Uq4QgCghtY0vVehkaOYQI22KCI83tlK 9bcAoLSJPVouY/3xSx0eZHs3wveq7WLf =jO+P -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--