Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 4
    Possible duplicate of Is micro-optimisation important when coding? Commented Apr 12, 2019 at 14:53
  • 20
    For what it's worth, your two code examples do not differ in number of responsibilities. The SRP is not a method counting exercise. Commented Apr 12, 2019 at 16:57
  • 2
    @RobertHarvey You're right, sorry for the poor example and I'll edit a better one when I have the time. In either case, readability and maintanability suffers and eventually the SRP breaks down within the codebase as we cut down on classes and their methods. Commented Apr 12, 2019 at 17:18
  • 4
    note that function calls are expensive in any language, though AOT compilers have the luxury of inlining Commented Apr 12, 2019 at 20:30
  • 6
    Use a JITted implementation of python such as PyPy. Should mostly fix this problem. Commented Apr 12, 2019 at 21:11