{"id":30663448,"url":"https://github.com/simpsonresearch/fastest_loops","last_synced_at":"2026-05-06T22:31:15.129Z","repository":{"id":62799164,"uuid":"562578039","full_name":"simpsonresearch/Fastest_Loops","owner":"simpsonresearch","description":"Fastest loops between Python, Rust, Golang","archived":false,"fork":false,"pushed_at":"2022-11-06T20:24:30.000Z","size":2498,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-14T23:39:37.260Z","etag":null,"topics":["fastest","golang","loops","python","rust"],"latest_commit_sha":null,"homepage":"https://simpson-computer-technologies-research.github.io/Fastest_Loops/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simpsonresearch.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":"2022-11-06T19:18:09.000Z","updated_at":"2022-11-06T20:02:14.000Z","dependencies_parsed_at":"2022-11-06T21:33:58.929Z","dependency_job_id":null,"html_url":"https://github.com/simpsonresearch/Fastest_Loops","commit_stats":null,"previous_names":["simpsonresearch/fastest_loops"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/simpsonresearch/Fastest_Loops","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2FFastest_Loops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2FFastest_Loops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2FFastest_Loops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2FFastest_Loops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simpsonresearch","download_url":"https://codeload.github.com/simpsonresearch/Fastest_Loops/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2FFastest_Loops/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32714696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T19:35:05.142Z","status":"ssl_error","status_checked_at":"2026-05-06T19:35:03.996Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fastest","golang","loops","python","rust"],"created_at":"2025-08-31T17:11:20.568Z","updated_at":"2026-05-06T22:31:15.095Z","avatar_url":"https://github.com/simpsonresearch.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastest Loops ![Stars](https://img.shields.io/github/stars/Simpson-Computer-Technologies-Research/Fastest_Loops?color=brightgreen) ![Watchers](https://img.shields.io/github/watchers/Simpson-Computer-Technologies-Research/Fastest_Loops?label=Watchers)\n![banner](https://user-images.githubusercontent.com/75189508/200192635-8b052e64-585b-4b15-bacb-b1457cd500ab.png)\nWhat are the Fastest loops between Python, Rust, Golang?\n\n# Results\n\u003ch3\u003ePython\u003c/h3\u003e\n\n```py\n \u003e\u003e While Loop:         0.624s\n\n \u003e\u003e Counted For Loop:   0.284s\n\n \u003e\u003e For Loop:           0.173s\n```\n\n\u003ch3\u003eGolang\u003c/h3\u003e\n\n```py\n \u003e\u003e While Loop:     2.3914ms\n\n \u003e\u003e Counted Loop:   1.9946ms\n\n \u003e\u003e Range Loop:     1.9947ms\n```\n\n\u003ch3\u003eRust (with --release)\u003c/h3\u003e\n\n```py\n # // ns (nanosecond) is 1 Millisecond / 1,000,000\n \n \u003e\u003e While Loop:         0ns\n\n \u003e\u003e Counted For Loop:   0ns\n\n \u003e\u003e For Loop:           0ns\n\n \u003e\u003e Iter Loop:          0ns\n```\n\n\u003ch3\u003eRust (not with --release)\u003c/h3\u003e\n\n```py\n \u003e\u003e While Loop:         48ms\n\n \u003e\u003e Counted For Loop:   124ms\n\n \u003e\u003e For Loop:           173ms\n\n \u003e\u003e Iter Loop:          194ms\n```\n\n# Functions\n\n\u003ch3\u003ePython\u003c/h3\u003e\n\n```py\n# // 10,000,000 Values\ndata: list[str] = [1 for _ in range(10 ** 7)]\n\n# // While Loop\ndef while_loop():\n    start_time: int = time.time()\n    i: int = 0\n    while i \u003c len(data):\n        i += 1\n    print(\"\\nWhile Loop: \"+str(time.time() - start_time))\n\n\n# // Counted loop\ndef counted_for_loop():\n    start_time: int = time.time()\n    for i in range(len(data)):\n        i += 0\n    print(\"\\nCounted For Loop: \"+str(time.time() - start_time))\n\n\n# // Variable Loop\ndef for_loop():\n    start_time: int = time.time()\n    for i in data:\n        i += 0\n    print(\"\\nFor Loop: \"+str(time.time() - start_time))\n```\n\n\u003ch3\u003eGolang\u003c/h3\u003e\n\n```go\n// Main function\nfunc main() {\n\tvar data []int = []int{}\n\tfor i := 0; i \u003c 10_000_000; i++ {\n\t\tdata = append(data, i)\n\t}\n\tWhileLoop(data)\n\tCountedLoop(data)\n\tRangeLoop(data)\n}\n\n// WhileLoop\nfunc WhileLoop(data []int) {\n\tvar (\n\t\tstartTime time.Time = time.Now()\n\t\ti         int       = 0\n\t)\n\tfor i \u003c len(data) {\n\t\ti++\n\t}\n\tfmt.Printf(\"\\nWhile Loop: %v\\n\", time.Since(startTime))\n}\n\n// Counted Loop\nfunc CountedLoop(data []int) {\n\tvar startTime time.Time = time.Now()\n\tfor i := 0; i \u003c len(data); i++ {\n\t\ti += 0\n\t}\n\tfmt.Printf(\"\\nCounted Loop: %v\\n\", time.Since(startTime))\n}\n\n// Range Loop\nfunc RangeLoop(data []int) {\n\tvar startTime time.Time = time.Now()\n\tfor _, v := range data {\n\t\tv += 0\n\t}\n\tfmt.Printf(\"\\nRange Loop: %v\\n\", time.Since(startTime))\n}\n```\n\n\u003ch3\u003eRust\u003c/h3\u003e\n\n```rust\nfn main() {\n    // Create the array and fill it with numbers\n    let mut data: Vec\u003ci64\u003e = vec![];\n    for i in 0..10_000_000 {\n        data.push(i as i64)\n    }\n\n    // Call the functions\n    while_loop(\u0026data);\n    counted_loop(\u0026data);\n    for_loop(\u0026data);\n    iter_loop(\u0026data);\n}\n\n// Function to get the current time since epoch in milliseconds\nfn get_start_time() -\u003e u128 {\n    return std::time::SystemTime::now()\n        .duration_since(std::time::UNIX_EPOCH).unwrap().as_millis();\n}\n\n// While Loop\nfn while_loop(data: \u0026[i64]) {\n    let start_time: u128 = get_start_time();\n    let mut i: i64 = 0;\n    while i \u003c data.len().try_into().unwrap() {\n        i += 1;\n    }\n    println!(\"While Loop: {}ms\", get_start_time() - start_time);\n}\n\n// Counted For Loop \nfn counted_loop(data: \u0026[i64]) {\n    let start_time: u128 = get_start_time();\n    let mut i: i64 = 0;\n    for _ in 1..data.len() {\n        i += 1;\n    }\n    println!(\"Counted For Loop: {}ms\", get_start_time() - start_time);\n}\n\n// For Loop\nfn for_loop(data: \u0026[i64]) {\n    let start_time: u128 = get_start_time();\n    let mut i: i64 = 0;\n    for _ in data {\n        i += 1;\n    }\n    println!(\"For Loop: {}ms\", get_start_time() - start_time);\n}\n\n// Loop using Iter and ForEach\nfn iter_loop(data: \u0026[i64]) {\n    let start_time: u128 = get_start_time();\n    let mut i: i64 = 0;\n    data.iter().for_each(|_| {\n        i += 1;\n    });\n    println!(\"Iter Loop: {}ms\", get_start_time() - start_time);\n}\n```\n\n# License\nMIT License\n\nCopyright (c) 2022 Tristan Simpson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Ffastest_loops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpsonresearch%2Ffastest_loops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Ffastest_loops/lists"}