Why are Python Files So Big?
November 12, 2009
I was casually negotiating through our code base and noticed that all
the Python files were larger than the Java files. It averaged 10k
lines for Java and 30k lines for Python. Notably there were a number
of VERY LARGE Java files that were auto-generated, and the median file
size was closer to 5k. Python files were more uniform.
Obviously Java restricts public classes to their own files whereas
Python doesn't, so there is a forcing factor there. But it just didn't
feel right. Upon closer inspection, it was clear that the average
Python class was also much larger than the average Java class.
The bit that stands out most vividly for me is the number of massive,
in-line Python methods. Lots of methods that are 200 lines. Very few
in Java. And in the several cases where I have translated the Python
into Java, I broke those puppies up. (I can't read and understand
methods that are that large. Maybe I'm just not very smart?)
The authors of the Python and Java code are all the same. We all write
in both languages. In general, the type of code is the same in both
So why are the Python files so big??