{"id":17220689,"url":"https://github.com/v0dro/array2hash","last_synced_at":"2026-06-19T01:31:35.136Z","repository":{"id":62553535,"uuid":"101668775","full_name":"v0dro/array2hash","owner":"v0dro","description":"Efficient conversion of a Ruby Array to a lookup table-like Hash written in Rubex.","archived":false,"fork":false,"pushed_at":"2017-09-17T13:34:19.000Z","size":59,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-02T14:05:40.545Z","etag":null,"topics":["performance","ruby"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v0dro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-28T17:26:02.000Z","updated_at":"2017-08-28T18:38:26.000Z","dependencies_parsed_at":"2022-11-03T04:45:24.094Z","dependency_job_id":null,"html_url":"https://github.com/v0dro/array2hash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/v0dro/array2hash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0dro%2Farray2hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0dro%2Farray2hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0dro%2Farray2hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0dro%2Farray2hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v0dro","download_url":"https://codeload.github.com/v0dro/array2hash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0dro%2Farray2hash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34514282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["performance","ruby"],"created_at":"2024-10-15T03:52:55.668Z","updated_at":"2026-06-19T01:31:35.109Z","avatar_url":"https://github.com/v0dro.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# array2hash\nEfficient conversion of a Ruby Array to a lookup table-like Hash written in Rubex.\n\nThis Ruby gem is a C extension written in [Rubex]() that can convert a Ruby Array to a Hash lookup table. Basically the following Array:\n``` ruby\n[\"1\", 2, :three, \"4\"]\n```\n...will be converted into a Hash that looks like this:\n``` ruby\n{\n  \"1\" =\u003e 0,\n   2 =\u003e 1,\n   :three =\u003e 2,\n   \"4\" =\u003e 3\n}\n```\n\nThe reason for making this gem is mainly speed. The conventional way of the above conversion would be as follows:\n``` ruby\na = [\"1\", 2, :three, \"4\"]\na.each_with_index.to_h \n```\n\nThis extension makes the above process upto 50% faster with a C extension. Here is the benchmarking code:\n``` ruby\nrequire 'benchmark/ips'\na = (1..1000).to_a.map(\u0026:to_s)\nBenchmark.ips do |x|\n  x.report(\"convert\") do\n    Array2Hash.convert a\n  end\n\n  x.report(\"each_with_index.to_h\") do\n    a.each_with_index.to_h\n  end\n\n  x.compare!\nend\n```\n\nThe results are as follows:\n```\nWarming up --------------------------------------\n             convert   368.000  i/100ms\neach_with_index.to_h   236.000  i/100ms\nCalculating -------------------------------------\n             convert      3.488k (± 9.8%) i/s -     17.296k in   5.012260s\neach_with_index.to_h      2.192k (± 8.3%) i/s -     11.092k in   5.097432s\n\nComparison:\n             convert:     3487.8 i/s\neach_with_index.to_h:     2192.3 i/s - 1.59x  slower\n```\n\n# Usage\n\nInstall with `gem install array2hash`.\n\nThe use with the `convert` class method:\n``` ruby\nrequire 'array2hash'\n\na = (1..1000).to_a.map(\u0026:to_s)\nArray2Hash.convert a\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0dro%2Farray2hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv0dro%2Farray2hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0dro%2Farray2hash/lists"}