Estendendo e incorporando o interpretador Python
************************************************

This document describes how to write modules in C or C++ to extend the
Python interpreter with new modules.  Those modules can do what Python
code does -- define functions, object types and methods -- but also
interact with native libraries or achieve better performance by
avoiding the overhead of an interpreter.  The document also describes
how to embed the Python interpreter in another application, for use as
an extension language.  Finally, it shows how to compile and link
extension modules so that they can be loaded dynamically (at run time)
into the interpreter, if the underlying operating system supports this
feature.

This document assumes basic knowledge about C and Python.  For an
informal introduction to Python, see O tutorial do Python.  A
Referência da Linguagem Python gives a more formal definition of the
language.  A Biblioteca Padrão do Python documents the existing object
types, functions and modules (both built-in and written in Python)
that give the language its wide application range.

Para uma descrição detalhada de toda a API Python/C, consulte o Manual
de referência da API C/Python separado.

To support extensions, Python's C API (Application Programmers
Interface) defines a set of functions, macros and variables that
provide access to most aspects of the Python run-time system.  The
Python API is incorporated in a C source file by including the header
""Python.h"".

Nota:

  A interface de extensões em C é específica para o CPython, e módulos
  de extensão não funcionam em outras implementações do Python.  Em
  muitos casos, é possível evitar a criação destas extensões em C e
  preservar a portabilidade para outras implementações. Por exemplo,
  se o seu caso de uso for o de fazer chamadas a funções em
  bibliotecas C ou chamadas de sistema, considere utilizar o módulo
  "ctypes" ou a biblioteca cffi ao invés de escrever código C
  personalizado. Esses módulos permitem escrever código Python que
  pode interoperar com código C e que é mais portável entre
  implementações do Python do que escrever e compilar um módulo de
  extensão em C.


Ferramentas de terceiros recomendadas
=====================================

This document only covers the basic tools for creating extensions
provided as part of this version of CPython. Some third party tools
offer both simpler and more sophisticated approaches to creating C and
C++ extensions for Python.

While this document is aimed at extension authors, it should also be
helpful to the authors of such tools. For example, the tutorial module
can serve as a simple test case for a build tool or sample expected
output of a code generator.


C API Tutorial
==============

This tutorial describes how to write a simple module in C or C++,
using the Python C API -- that is, using the basic tools provided as
part of this version of CPython.

1. Your first C API extension module


Guides for intermediate topics
==============================

Esta seção do guia aborda a criação de extensões C e C++ sem
assistência de ferramentas de terceiros. Destina-se principalmente aos
criadores dessas ferramentas, em vez de ser uma maneira recomendada de
criar suas próprias extensões C.

* Using the C API: Assorted topics

* Definindo Tipos de Extensão: Tutorial

* Defining Extension Types: Assorted Topics

* Construindo extensões C e C++

* Construindo Extensões C e C++ no Windows


Incorporando o tempo de execução do CPython em uma aplicação maior
==================================================================

Às vezes, em vez de criar uma extensão que é executada dentro do
interpretador Python como a aplicação principal, é desejável
incorporar o tempo de execução do CPython em uma aplicação maior. Esta
seção aborda alguns dos detalhes envolvidos para fazer isso com êxito.

* Incorporando o Python numa Outra Aplicação
