모듈 임포트 하기
****************

PyObject* PyImport_ImportModule(const char *name)
    *Return value: New reference.*

   This is a simplified interface to "PyImport_ImportModuleEx()"
   below, leaving the *globals* and *locals* arguments set to "NULL"
   and *level* set to 0.  When the *name* argument contains a dot
   (when it specifies a submodule of a package), the *fromlist*
   argument is set to the list "['*']" so that the return value is the
   named module rather than the top-level package containing it as
   would otherwise be the case.  (Unfortunately, this has an
   additional side effect when *name* in fact specifies a subpackage
   instead of a submodule: the submodules specified in the package's
   "__all__" variable are  loaded.)  Return a new reference to the
   imported module, or "NULL" with an exception set on failure.  A
   failing import of a module doesn't leave the module in
   "sys.modules".

   이 함수는 항상 절대 임포트를 사용합니다.

PyObject* PyImport_ImportModuleNoBlock(const char *name)
    *Return value: New reference.*

   이 함수는 "PyImport_ImportModule()"의 폐지된 별칭입니다.

   버전 3.3에서 변경: 이 기능은 다른 스레드가 임포트 잠금을 보유한 경
   우 즉시 실패했었습니다. 그러나 파이썬 3.3에서는, 잠금 방식이 대부분
   의 목적에서 모듈 단위 잠금으로 전환되었기 때문에, 이 함수의 특수한
   동작은 더는 필요하지 않습니다.

PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
    *Return value: New reference.*

   모듈을 임포트 합니다. 내장 파이썬 함수 "__import__()"를 통해 가장
   잘 설명할 수 있습니다.

   The return value is a new reference to the imported module or top-
   level package, or "NULL" with an exception set on failure.  Like
   for "__import__()", the return value when a submodule of a package
   was requested is normally the top-level package, unless a non-empty
   *fromlist* was given.

   임포트 실패는 "PyImport_ImportModule()"처럼 불완전한 모듈 객체를 제
   거합니다.

PyObject* PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
    *Return value: New reference.*

   모듈을 임포트 합니다. 표준 "__import__()" 함수가 이 함수를 직접 호
   출하기 때문에, 내장 파이썬 함수 "__import__()"를 통해 가장 잘 설명
   할 수 있습니다.

   The return value is a new reference to the imported module or top-
   level package, or "NULL" with an exception set on failure.  Like
   for "__import__()", the return value when a submodule of a package
   was requested is normally the top-level package, unless a non-empty
   *fromlist* was given.

   버전 3.3에 추가.

PyObject* PyImport_ImportModuleLevel(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
    *Return value: New reference.*

   "PyImport_ImportModuleLevelObject()"와 비슷하지만, name은 유니코드
   객체 대신 UTF-8로 인코딩된 문자열입니다.

   버전 3.3에서 변경: *level*의 음수 값은 더는 허용되지 않습니다.

PyObject* PyImport_Import(PyObject *name)
    *Return value: New reference.*

   이것은 현재 "임포트 훅 함수"를 호출하는 고수준 인터페이스입니다 (명
   시적인 *level* 0을 사용하는데, 절대 임포트를 뜻합니다). 현재 전역의
   "__builtins__"에 있는 "__import__()" 함수를 호출합니다. 이는 현재
   환경에 설치된 임포트 훅을 사용하여 임포트가 수행됨을 의미합니다.

   이 함수는 항상 절대 임포트를 사용합니다.

PyObject* PyImport_ReloadModule(PyObject *m)
    *Return value: New reference.*

   Reload a module.  Return a new reference to the reloaded module, or
   "NULL" with an exception set on failure (the module still exists in
   this case).

PyObject* PyImport_AddModuleObject(PyObject *name)
    *Return value: Borrowed reference.*

   Return the module object corresponding to a module name.  The
   *name* argument may be of the form "package.module". First check
   the modules dictionary if there's one there, and if not, create a
   new one and insert it in the modules dictionary. Return "NULL" with
   an exception set on failure.

   참고:

     이 함수는 모듈을 로드하거나 임포트 하지 않습니다; 모듈이 아직 로
     드되지 않았으면, 빈 모듈 객체를 얻게 됩니다. 모듈을 임포트 하려면
     "PyImport_ImportModule()"이나 그 변형 중 하나를 사용하십시오.
     *name*에서 점으로 구분된 이름으로 암시된 패키지 구조는 이미 존재
     하지 않는다면 만들어지지 않습니다.

   버전 3.3에 추가.

PyObject* PyImport_AddModule(const char *name)
    *Return value: Borrowed reference.*

   "PyImport_AddModuleObject()"와 비슷하지만, name은 유니코드 객체 대
   신 UTF-8로 인코딩된 문자열입니다.

PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
    *Return value: New reference.*

   Given a module name (possibly of the form "package.module") and a
   code object read from a Python bytecode file or obtained from the
   built-in function "compile()", load the module.  Return a new
   reference to the module object, or "NULL" with an exception set if
   an error occurred.  *name* is removed from "sys.modules" in error
   cases, even if *name* was already in "sys.modules" on entry to
   "PyImport_ExecCodeModule()".  Leaving incompletely initialized
   modules in "sys.modules" is dangerous, as imports of such modules
   have no way to know that the module object is an unknown (and
   probably damaged with respect to the module author's intents)
   state.

   모듈의 "__spec__"과 "__loader__"는 아직 설정되지 않았다면 적절한 값
   으로 설정됩니다. 스펙의 로더는 모듈의 "__loader__"(설정되었다면)로
   설정되고, 그렇지 않으면 "SourceFileLoader" 의 인스턴스로 설정됩니다
   .

   모듈의 "__file__" 어트리뷰트는 코드 객체의 "co_filename"으로 설정됩
   니다. 해당한다면, "__cached__"도 설정됩니다.

   이 함수는 이미 임포트 되었다면 모듈을 다시 로드합니다. 모듈을 다시
   로드하는 의도된 방법은 "PyImport_ReloadModule()"을 참조하십시오.

   *name*이 "package.module" 형식의 점으로 구분된 이름을 가리키면, 이
   미 만들어지지 않은 패키지 구조는 여전히 만들어지지 않습니다.

   "PyImport_ExecCodeModuleEx()"와
   "PyImport_ExecCodeModuleWithPathnames()"도 참조하십시오.

PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
    *Return value: New reference.*

   "PyImport_ExecCodeModule()"과 유사하지만, 모듈 객체의 "__file__" 어
   트리뷰트는 "NULL"이 아니라면 *pathname*으로 설정됩니다.

   "PyImport_ExecCodeModuleWithPathnames()"도 참조하십시오.

PyObject* PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, PyObject *cpathname)
    *Return value: New reference.*

   "PyImport_ExecCodeModuleEx()"와 유사하지만, 모듈 객체의
   "__cached__" 어트리뷰트는 "NULL"이 아니라면 *cpathname*으로 설정됩
   니다. 세 가지 함수 중 이것이 선호되는 것입니다.

   버전 3.3에 추가.

PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
    *Return value: New reference.*

   "PyImport_ExecCodeModuleObject()"와 유사하지만, *name*, *pathname*
   및 *cpathname*은 UTF-8로 인코딩된 문자열입니다. *pathname*의 값이
   "NULL"로 설정된 경우 어떤 값이 *cpathname*에서 와야하는지 알아내려
   고 합니다.

   버전 3.2에 추가.

   버전 3.3에서 변경: 바이트 코드 경로만 제공되면 소스 경로를 계산할
   때 "imp.source_from_cache()"를 사용합니다.

long PyImport_GetMagicNumber()

   파이썬 바이트 코드 파일(일명 ".pyc" 파일)의 매직 번호(magic number)
   를 반환합니다. 매직 번호는 바이트 코드 파일의 처음 4바이트에 리틀
   엔디안 바이트 순서로 존재해야 합니다. 에러 시 "-1"을 반환합니다.

   버전 3.3에서 변경: 실패 시 "-1"을 반환합니다.

const char * PyImport_GetMagicTag()

   **PEP 3147** 형식 파이썬 바이트 코드 파일 이름의 매직 태그 문자열을
   반환합니다. "sys.implementation.cache_tag"의 값은 신뢰할 수 있고 이
   함수 대신 사용해야 함에 유의하십시오.

   버전 3.2에 추가.

PyObject* PyImport_GetModuleDict()
    *Return value: Borrowed reference.*

   모듈 관리에 사용되는 딕셔너리(일명 "sys.modules")를 반환합니다. 이
   것은 인터프리터마다 존재하는 변수임에 유의하십시오.

PyObject* PyImport_GetModule(PyObject *name)
    *Return value: New reference.*

   Return the already imported module with the given name.  If the
   module has not been imported yet then returns "NULL" but does not
   set an error.  Returns "NULL" and sets an error if the lookup
   failed.

   버전 3.7에 추가.

PyObject* PyImport_GetImporter(PyObject *path)
    *Return value: New reference.*

   "sys.path"/"pkg.__path__" 항목 *path*를 위한 파인더 객체를 반환합니
   다, "sys.path_importer_cache" 딕셔너리에서 꺼낼 수도 있습니다. 아직
   캐시 되지 않았으면, 경로 항목을 처리할 수 있는 훅이 발견될 때까지
   "sys.path_hooks"를 탐색합니다. 훅이 없으면 "None"을 반환합니다; 이
   것은 호출자에게 *경로 기반 파인더*가 이 경로 항목에 대한 파인더를
   찾을 수 없음을 알려줍니다. "sys.path_importer_cache"에 결과를 캐시
   합니다. 파인더 객체에 대한 새로운 참조를 반환합니다.

void _PyImport_Init()

   임포트 메커니즘을 초기화합니다. 내부 전용입니다.

void PyImport_Cleanup()

   모듈 테이블을 비웁니다. 내부 전용입니다.

void _PyImport_Fini()

   임포트 메커니즘을 마무리합니다. 내부 전용입니다.

int PyImport_ImportFrozenModuleObject(PyObject *name)
    *Return value: New reference.*

   *name*이라는 이름의 프로즌 모듈(frozen module)을 로드합니다. 성공하
   면 "1"을, 모듈을 찾지 못하면 "0"을, 초기화에 실패하면 예외를 설정하
   고 "-1"을 반환합니다. 로드가 성공할 때 임포트 된 모듈에 액세스하려
   면 "PyImport_ImportModule()"을 사용하십시오. (잘못된 이름에 주의하
   십시오 --- 이 함수는 모듈이 이미 임포트 되었을 때 다시 로드합니다.)

   버전 3.3에 추가.

   버전 3.4에서 변경: "__file__" 어트리뷰트는 더는 모듈에 설정되지 않
   습니다.

int PyImport_ImportFrozenModule(const char *name)

   "PyImport_ImportFrozenModuleObject()"와 비슷하지만, name은 유니코드
   객체 대신 UTF-8로 인코딩된 문자열입니다.

struct _frozen

   이것은 **freeze** 유틸리티(파이썬 소스 배포의 "Tools/freeze/"를 참
   조하십시오)가 생성한 프로즌 모듈 디스크립터를 위한 구조체 형 정의입
   니다. "Include/import.h"에 있는 정의는 다음과 같습니다:

      struct _frozen {
          const char *name;
          const unsigned char *code;
          int size;
      };

const struct _frozen* PyImport_FrozenModules

   This pointer is initialized to point to an array of "struct
   _frozen" records, terminated by one whose members are all "NULL" or
   zero.  When a frozen module is imported, it is searched in this
   table.  Third-party code could play tricks with this to provide a
   dynamically created collection of frozen modules.

int PyImport_AppendInittab(const char *name, PyObject* (*initfunc)(void))

   기존의 내장 모듈 테이블에 단일 모듈을 추가합니다. 이것은
   "PyImport_ExtendInittab()"을 감싸는 편리한 래퍼인데, 테이블을 확장
   할 수 없으면 "-1"을 반환합니다. 새 모듈은 *name*이라는 이름으로 임
   포트 될 수 있으며, *initfunc* 함수를 처음 시도한 임포트에서 호출되
   는 초기화 함수로 사용합니다. "Py_Initialize()" 전에 호출해야 합니다
   .

struct _inittab

   내장 모듈 목록에 있는 단일 항목을 기술하는 구조체. 각 구조체는 인터
   프리터에 내장된 모듈의 이름과 초기화 함수를 제공합니다. 이름은
   ASCII로 인코딩된 문자열입니다. 파이썬을 내장하는 프로그램은
   "PyImport_ExtendInittab()"과 함께 이러한 구조체의 배열을 사용하여
   추가 내장 모듈을 제공 할 수 있습니다. 구조체는 "Include/import.h"에
   서 다음과 같이 정의됩니다:

      struct _inittab {
          const char *name;           /* ASCII encoded string */
          PyObject* (*initfunc)(void);
      };

int PyImport_ExtendInittab(struct _inittab *newtab)

   Add a collection of modules to the table of built-in modules.  The
   *newtab* array must end with a sentinel entry which contains "NULL"
   for the "name" field; failure to provide the sentinel value can
   result in a memory fault. Returns "0" on success or "-1" if
   insufficient memory could be allocated to extend the internal
   table.  In the event of failure, no modules are added to the
   internal table.  This should be called before "Py_Initialize()".
