|
Download code/bad007.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/bad007.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/bad007.jsonl
-
curl -L -o bad007.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/bad007.jsonl
2.2 kB
| {"type": "session", "harness": "deepseek-harness", "id": "bad007", "name": "Performance anti-patterns"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "What are common performance anti-patterns?"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Bad Practices:**\n\n1. **N+1 Query Problem:**\n```python\n# Bad: queries inside loop\nfor user in users:\n orders = db.query(f\"SELECT * FROM orders WHERE user_id={user.id}\")\n\n# Good: single query with JOIN\norders = db.query(\"SELECT * FROM orders WHERE user_id IN ?\", [user_ids])\n```\n\n2. **String Concatenation in Loop:**\n```python\n# Bad: O(n^2)\nresult = \"\"\nfor item in items:\n result += str(item)\n\n# Good: O(n)\nresult = \"\".join(str(item) for item in items)\n```\n\n3. **Unnecessary Computation:**\n```python\n# Bad: recomputing in loop\nfor i in range(len(data)):\n processed = expensive_function(data[i]) # same result each time\n\n# Good: compute once\ncached = expensive_function(data[0])\nfor i in range(len(data)):\n use(cached)\n```\n\n4. **Loading Entire File Into Memory:**\n```python\n# Bad: memory issues with large files\ndata = open(\"huge_file.txt\").read()\n\n# Good: process line by line\nwith open(\"huge_file.txt\") as f:\n for line in f:\n process(line)\n```\n\n5. **Premature Optimization:**\n```python\n# Bad: optimizing rarely-used code\n@lru_cache(maxsize=10000)\ndef rarely_called(x):\n return x * 2\n\n# Good: profile first, optimize bottlenecks\n```\n\n6. **Blocking I/O in Async Code:**\n```python\n# Bad\nasync def fetch():\n data = requests.get(url) # blocks entire event loop\n\n# Good\nasync def fetch():\n async with aiohttp.ClientSession() as session:\n data = await session.get(url)\n```"}} | |