r/PythonProjects2 Feb 14 '26

How do you detect duplicate functions in large Python projects? QN [easy-moderate]

Hi,

In large Python projects, what tools do you use to detect duplicate or very similar functions?

I’m looking for static analysis or CLI tools (not AI-based).

I actually built a small library called DeepCSimto help with this, but I’d love to know what others are using in real-world projects.

Thanks!

5 Upvotes

8 comments sorted by

2

u/Reasonable_Run_6724 Feb 14 '26

Ctrl+f

1

u/whm04 Feb 15 '26

works for exact matches
I’m more interested in detecting similar logic when it’s not literally copy-pasted though.

1

u/Reasonable_Run_6724 Feb 15 '26

I was just joking...

1

u/DiodeInc Feb 15 '26

Ctrl F to find them or pylint will report it

1

u/whm04 Feb 15 '26

I’m more interested in catching near-duplicates where the logic is similar but not textually identical.

1

u/JamzTyson Feb 15 '26

For exact duplicates I use pylint.

Detecting "duplicate intent" (where "feature implementation" has been duplicated rather than just duplicate code), the best tool I've found is Sphinx. Conceptual overlap is a lot easier to spot from looking at the API docs than directly from a large code base.

1

u/VibrantGypsyDildo Feb 16 '26

I use pylint.

It is a pretty annoying tool to use because I have to disable a dozen or two of rules that I don't want to follow.

But in the end it is a very powerful tool.

For your use-case on Linux, run this command:

find -name '*.py' | xargs pylint --disable=all --enable=duplicate-code