Does lua optimize duplicate imports?

import, lua

Solution

Yes, Lua does.

As manual on `require` in section 5.3 says:

Loads the given module. The function starts by looking into the package.loaded table to determine whether modname is already loaded. If it is, then require returns the value stored at package.loaded[modname].

Problem

In simple model I have 3 files: ``` base-module.lua module-one.lua module-two.lua ``` And this is my import connections: ``` module-two.lua < --| ^ | | | | | module-one.lua | ^ | | | | | base-module.lua ---- ``` `module-one.lua` import `base-module.lua` and so on.... When I remove `base-module.lua` import from `module-two.lua` I see all functions and variables from `base-module.lua` but my imports is not inventive. Does lua optimize double import like it make pytho for example?

Original source