﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33917	Optimize ModelBase.__new__ app_label setup	Ivan Dominic Baguio	Ivan Dominic Baguio	"While browsing the ModelBase code, i noticed a possible improvement on the code logic.

under `ModelBase.__new__`, you will see:

{{{
        # Look for an application configuration to attach the model to.
        app_config = apps.get_containing_app_config(module)

        if getattr(meta, ""app_label"", None) is None:
            if app_config is None:
                # ...
            else:
                app_label = app_config.label
}}}

notice that `app_config` is defined above and outside the `if getattr` block. 
the `app_config` variable is only used **inside** the `if getattr` block.

it would make sense to move the `app_config` initialization inside the `if` block, so it doesn't get unnecessarily called.

i've double checked the following:
- `get_containing_app_config` doesn't have any side effects, and is only a getter method
- `app_config` is only needed inside the if block"	Cleanup/optimization	closed	Database layer (models, ORM)	4.0	Normal	wontfix	ModelBase		Unreviewed	1	0	0	0	1	0
