What is the best AI...
 
Notifications
Clear all

What is the best AI for writing complex Python code?

5 Posts
6 Users
0 Reactions
373 Views
0
Topic starter

Ive been trying to automate this messy inventory system for my uncles hardware store here in Seattle and the python scripts are getting pretty huge. Ive been looking around and people keep saying Claude 3.5 Sonnet is the king for coding now because it follows logic better but then I see others swearing by GPT-4o for its speed and better ecosystem.

Im worried about the AI just hallucinating libraries or losing track of the file structure when things get complex. I have about 50 bucks to spend on a subscription this month so I really only want to pick one. Which one is actually better for handling deep nested logic and classes without breaking?


5 Answers
12

Honestly, if you're dealing with deep nested logic for an inventory system, I would suggest going with Anthropic Claude 3.5 Sonnet. Ive used both for huge projects and Claude is way less likely to get lazy or hallucinate weird syntax when the file gets long. OpenAI GPT-4o is fast, but it tends to trim code blocks which is super annoying for keeping classes consistent. A few things to be careful about:

  • You might want to consider breaking scripts into smaller modules instead of one giant file.
  • Make sure to use the Projects feature in the Anthropic Claude 3.5 Sonnet paid plan. It lets you upload your file structure so it stays on track.
  • Be careful with the context window; even the best AI can lose the thread if you dump too much data. Its definitely worth the subscription. Let me know if you need help with the hardware store logic!


10

Cursor is better for nested logic:

  • Cursor AI Code Editor Pro indexes your whole project.
  • GitHub Copilot Individual is fast but misses context. Wont work well if logic is tangled tho.


2

Just found this thread and honestly, I'm in the exact same boat with a legacy inventory system I'm trying to patch up. It's exhausting. My biggest piece of advice is to watch out for context drift once your classes get nested. These AIs look smart until they start hallucinating methods that dont exist because the file got too long for them to track. I've wasted so much time and money fixing refactors that actually broke my logic because I let the script get too messy... it'll cost you more in debugging time than the subscription is worth. Be careful about just blindly trusting the output when youre working on deep logic, it kinda sucks when it happens. TL;DR: Keep your files small and your functions isolated or you'll burn your budget on garbage code that doesn't actually run.


2

> Im worried about the AI just hallucinating libraries or losing track of the file structure when things get complex. Coming back to this after lunch... honestly been there with the inventory mess. over the years ive tried many setups and context drift is the ultimate killer. in my experience, if you are really worried about it losing track of your files, Google Gemini 1.5 Pro is actually a sleeper hit. i used it for a massive legacy refactor recently and it didnt break a sweat because of that million-token context window. it basically sees your whole project at once so it wont forget that weird class you wrote three hours ago. tbh though, if you want pure raw logic, DeepSeek V3 has been blowing my mind lately. its super cheap and handles deep nested python classes with way more precision than gpt-4o imo. deepseek feels more like it actually understands the architecture while gemini is the king of context. both are solid but id probably grab the gemini sub if your scripts are getting truly massive... just saves so much headache with hallucinations since it can actually 'read' the whole folder.


1

To add to the point above: honestly, you might want to consider Phind Pro AI Coding Assistant for this. its basically a search engine for devs that uses gpt-4o but verifies stuff against actual documentation.

  • way fewer hallucinations of methods
  • great for big file structures
  • fits well within your budget just keep an eye on how it handles imports tho... its way safer than raw gpt-4 for deep logic.


Share: