{"id":20997523,"url":"https://github.com/cdump/gomapcompile","last_synced_at":"2025-03-13T13:21:13.239Z","repository":{"id":188805603,"uuid":"617610798","full_name":"cdump/gomapcompile","owner":"cdump","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-22T18:41:10.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T09:12:32.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdump.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-22T18:39:58.000Z","updated_at":"2023-03-22T18:41:14.000Z","dependencies_parsed_at":"2023-08-16T23:45:26.643Z","dependency_job_id":"3466b8ce-ac7e-4e80-a908-daa7a137a5c3","html_url":"https://github.com/cdump/gomapcompile","commit_stats":null,"previous_names":["cdump/gomapcompile"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdump%2Fgomapcompile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdump%2Fgomapcompile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdump%2Fgomapcompile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdump%2Fgomapcompile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdump","download_url":"https://codeload.github.com/cdump/gomapcompile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243410491,"owners_count":20286424,"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-11-19T07:40:07.916Z","updated_at":"2025-03-13T13:21:13.211Z","avatar_url":"https://github.com/cdump.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go map with slice/array compile time/memory\n\n## Numbers\nCompilation time \u0026 memory usage:\n\n`go version go1.20.2 linux/amd64`\n\n- 22.49s vs 2.16s\n- 2260Mb vs 234Mb\n\n## Code\n```go\ntype MyStruct struct {\n    a string\n    b [32]int\n    c []int\n}\n```\n\nSlow slice:\n```go\nvar b2c = map[uint32]MyStruct{\n    0: MyStruct{\n        a: \" 0 \",\n        c: []int{ 0 },\n    },\n    7: MyStruct{\n        a: \" 1 \",\n        c: []int{ 1 },\n    },\n    ...\n}\n```\n\nFast array:\n```go\nvar b2c = map[uint32]MyStruct{\n    0: MyStruct{\n        a: \" 0 \",\n        b: [32]int{ 0 },\n    },\n    7: MyStruct{\n        a: \" 1 \",\n        b: [32]int{ 1 },\n    },\n    ...\n}\n```\n\n## Reproducer\n```sh\n$ make array\npython3 a.py 50000 array \u003e src/slow.go\n/usr/bin/time -v go build -o slow ./src |\u0026 grep -E 'wall clock|Maximum resident set'\n        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.16\n        Maximum resident set size (kbytes): 234332\n\n$ make slice\npython3 a.py 50000 slice \u003e src/slow.go\n/usr/bin/time -v go build -o /dev/null ./src |\u0026 grep -E 'wall clock|Maximum resident set'\n        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:22.49\n        Maximum resident set size (kbytes): 2260508\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdump%2Fgomapcompile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdump%2Fgomapcompile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdump%2Fgomapcompile/lists"}