{"id":16906547,"url":"https://github.com/rsms/go-immutable","last_synced_at":"2025-03-22T10:31:13.031Z","repository":{"id":66105779,"uuid":"315767901","full_name":"rsms/go-immutable","owner":"rsms","description":"Immutable data structures for Go","archived":false,"fork":false,"pushed_at":"2020-12-01T16:31:31.000Z","size":43,"stargazers_count":35,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T21:17:04.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-24T22:30:08.000Z","updated_at":"2025-03-04T21:13:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6609f9d-c9e8-42c5-943a-045660a89706","html_url":"https://github.com/rsms/go-immutable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-immutable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-immutable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-immutable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-immutable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsms","download_url":"https://codeload.github.com/rsms/go-immutable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943732,"owners_count":20536290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-13T18:43:11.921Z","updated_at":"2025-03-22T10:31:12.725Z","avatar_url":"https://github.com/rsms.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Immutable data structures for Go\n\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/rsms/go-immutable.svg)][godoc]\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/rsms/go-immutable)][godoc]\n[![Go Report Card](https://goreportcard.com/badge/github.com/rsms/go-immutable)](https://goreportcard.com/report/github.com/rsms/go-immutable)\n\n[godoc]: https://pkg.go.dev/github.com/rsms/go-immutable\n\n- Based on a immutable persistent Hash Array Mapped Trie (HAMT)\n- Minimal interface to the core HAMT implementation so that you can easily\n  implement your own structures on top of it.\n- Comes with some set and map implementations ready to go\n- Inspired by Clojure's data structures\n- Excellent performance (lookup is about the same as native go maps,\n  insertion about 20% that of mutable native go maps.)\n\nExample:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/rsms/go-immutable\"\n)\n\nm := immutable.EmptyStrMap\n\nm1 := m.Set(\"Hello\", 123)\nm2 := m.Set(\"Hello\", 456).Set(\"Sun\", 9)\nm3 := m2.Del(\"Hello\")\n\nfmt.Printf(\"m1: %s\\n\", m1)\nfmt.Printf(\"m2: %s\\n\", m2)\nfmt.Printf(\"m3: %s\\n\", m3)\n\n// Output:\n// m1: {\"Hello\": 123}\n// m2: {\"Sun\": 9, \"Hello\": 456}\n// m3: {\"Sun\": 9}\n```\n\n## Benchmark\n\n```\nTEST                            SAMPLES       TIME PER ITERATION\nBenchmarkHamtLookup_10          48042776          23.8 ns/op\nBenchmarkHamtLookup_100         36947116          31.0 ns/op\nBenchmarkHamtLookup_1000        32566189          34.8 ns/op\nBenchmarkHamtLookup_10000       24775086          49.1 ns/op\n\nBenchmarkGoMapLookup_10         69836985          16.3 ns/op\nBenchmarkGoMapLookup_100        66960720          16.5 ns/op\nBenchmarkGoMapLookup_1000       36865258          30.7 ns/op\nBenchmarkGoMapLookup_10000      28110822          43.3 ns/op\n\nBenchmarkHamtInsert_10           8019391         137.0 ns/op\nBenchmarkHamtInsert_25           6851881         174.0 ns/op\nBenchmarkHamtInsert_50           5419015         221.0 ns/op\nBenchmarkHamtInsert_100          3860596         293.0 ns/op\nBenchmarkHamtInsert_1000         2596484         469.0 ns/op\nBenchmarkHamtInsert_5000         1892996         644.0 ns/op\n\nBenchmarkGoMapInsert_10         17940093          66.5 ns/op\nBenchmarkGoMapInsert_25         13996856          74.3 ns/op\nBenchmarkGoMapInsert_50         14645752          83.3 ns/op\nBenchmarkGoMapInsert_100        14309284          82.8 ns/op\nBenchmarkGoMapInsert_1000       10754890         106.0 ns/op\nBenchmarkGoMapInsert_5000       11948517         100.0 ns/op\n```\n\nResults are from a 2018 MacBook Pro.\n`BenchmarkHamt*` and `BenchmarkGo*` are tests with same input using HAMT and native Go maps,\nrespectively.\nRun these benchmarks yourself with `./dev -bench`.\n\nKeep in mind that HAMT is immutable and derivative data structure which requires lots of\nmemory allocations, compared to the mutable in-place native go maps.\nI've chosen to compare the HAMT implementation with Go maps since Go maps are likely what\nyou are familiar with. :-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fgo-immutable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsms%2Fgo-immutable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fgo-immutable/lists"}