schrodingerscatcuriosity
schrodingerscatcuriosity

Reputation: 1860

Performance Django/Python calling modules

To the experts on Django/Python:

Is there a significative difference in performance between calling, as an example:

from foo.views import foo, foo2, #... and son on

than:

from foo import views

path('foo', views.foo, name="my_view"),
path('foo2', views.foo2, name="my_view")
# ... and so on

Having in mind of course that you have tons of views or other classes, methods, etc.

Upvotes: 0

Views: 32

Answers (1)

Anonymous
Anonymous

Reputation: 12090

There is no difference since after the application has initialized the result is exactly the same. When it is ready to receive requests there is literally zero difference.

One could argue that during initialization the attribute access in the 2nd example is an instruction or two longer, but it makes no practical difference.

As with all optimization questions, make sure it functions first and then perform some tests. Unless you re-initialize your app 100 times a second, you probably won't see any statistically significant differences even if you did test it.

Upvotes: 1

Related Questions