{"id":17077530,"url":"https://github.com/kwmsmith/typed-containers","last_synced_at":"2026-05-02T09:35:09.387Z","repository":{"id":4526909,"uuid":"5666996","full_name":"kwmsmith/typed-containers","owner":"kwmsmith","description":"Everything I wish Python dicts, lists, sets, etc. had, and more.","archived":false,"fork":false,"pushed_at":"2014-02-09T04:21:20.000Z","size":324,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T18:29:50.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/kwmsmith.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2012-09-04T03:27:22.000Z","updated_at":"2014-06-18T12:39:55.000Z","dependencies_parsed_at":"2022-07-21T09:32:36.186Z","dependency_job_id":null,"html_url":"https://github.com/kwmsmith/typed-containers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwmsmith%2Ftyped-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwmsmith%2Ftyped-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwmsmith%2Ftyped-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwmsmith%2Ftyped-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwmsmith","download_url":"https://codeload.github.com/kwmsmith/typed-containers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097834,"owners_count":20560319,"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-14T12:15:23.146Z","updated_at":"2026-05-02T09:35:09.323Z","avatar_url":"https://github.com/kwmsmith.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============================================================================\nTyped Containers\n==============================================================================\n\nPython containers -- lists, tuples, sets, and, especially, dictionaries -- are\nawesome.  They rank with Python's syntax, object model, and standard library\nas one of the most compelling feature of the language, and they are extremely\nwell designed.  Because they're used everywhere in the language itself\n(especially dicts), they have to be all things to all people, and they\naccomplish their task with aplomb.\n\nBut...\n\nWhat if you *know* that you need a dictionary of 32-bit unsigned int keys to\n10-character strings, you know from the outset that it will have 512**2\nkey-value pairs, and you know that its primary use is for creation and a few\niterations, with no deletions?  Can we do better than the one-size-fits-all\noption provided by the workhorse `dict()`?\n\nOf course we can.\n\nAt the other end of the spectrum, if we have a tiny dictionary of just 8 key /\nvalue pairs (chars to ints, for example) that will be used in an internal\nloop, can we optimize it so that the entire dictionary, including the keys /\nvalues, fits in two cache lines?\n\nYou betcha!\n\nFeatures and sketchy roadmap\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* Typing of dictionary keys, values.  What NumPy does for typed arrays, we do\n  for the Python dictionary.\n\n* User-tweakable parameters to control memory usage / sparsity, initial\n  dictionary size, and many more,\n\n* A clean C interface, with no Python dependency.  You can use the underlying\n  containers from your favorite systems language without having to think about\n  Python refcounting.\n\n* Clean Python wrappers over the C foundation.  When you ask for something\n  from a container, a new Python object is created for you, like Ctypes, or\n  NumPy.\n\n* Optimized memory usage for the base fixed-size types.  Dictionaries of\n  uint32 -\u003e float64 will use just 16 bytes per key / value pair on a 32-bit\n  system.  For fixed-sized element types, key / values are stored in the\n  dictionary itself; they are *not* stored in the dictionary as pointers.\n  This is to save pointer dereferencing, improve memory locality, and to\n  reduce memory usage.\n\nSome possible avenues to explore:\n\n* making a dictionary readonly, and the optimizations that a readonly dict\n  makes possible.\n\n* Different collision behavoir to reduce cache misses (sparsity is a factor\n  here as well).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwmsmith%2Ftyped-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwmsmith%2Ftyped-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwmsmith%2Ftyped-containers/lists"}