はじめに
********

この "Python ライブラリ" には様々な内容が収録されています。

このライブラリには、数値型やリスト型のような、通常は言語の "核" をなす
部分とみなされるデータ型が含まれています。Python 言語のコア部分では、
これらの型に対してリテラル表現形式を与え、意味づけ上のいくつかの制約を
与えていますが、完全にその意味づけを定義しているわけではありません。(
一方で、言語のコア部分では演算子のスペルや優先順位のような構文法的な属
性を定義しています。)

このライブラリにはまた、組み込み関数と例外が納められています --- 組み
込み関数および例外は、全ての Python で書かれたコード上で、 "import" 文
を使わずに使うことができるオブジェクトです。これらの組み込み要素のうち
いくつかは言語のコア部分で定義されていますが、大半は言語コアの意味づけ
上不可欠なものではないのでここでしか記述されていません。

とはいえ、このライブラリの大部分に収録されているのはモジュールのコレク
ションです。このコレクションを細分化する方法はいろいろあります。あるモ
ジュールは C 言語で書かれ、Python インタプリタに組み込まれています; 一
方別のモジュールは Python で書かれ、ソースコードの形式で取り込まれます
。またあるモジュールは、例えば実行スタックの追跡結果を出力するといった
、Python に非常に特化したインターフェースを提供し、一方他のモジュール
では、特定のハードウェアにアクセスするといった、特定のオペレーティング
システムに特化したインターフェースを提供し、さらに別のモジュールでは
WWW (ワールドワイドウェブ) のような特定のアプリケーション分野に特化し
たインターフェースを提供しています。モジュールによっては全てのバージョ
ン、全ての移植版の Python で利用することができたり、背後にあるシステム
がサポートしている場合にのみ使えたり、Python をコンパイルしてインスト
ールする際に特定の設定オプションを選んだときにのみ利用できたりします。

このマニュアルは "内部から外部へ" と構成されています。つまり、最初に組
み込みの関数を記述し、組み込みのデータ型、例外、そして最後に各モジュー
ルと続きます。モジュールは関係のあるものでグループ化して一つの章にして
います。

つまり、このマニュアルを最初から読み始め、読み飽きたところで次の章に進
めば、 Python ライブラリで利用できるモジュールやサポートしているアプリ
ケーション領域の概要をそこそこ理解できるということです。もちろん、この
マニュアルを小説のように読む必要は *ありません* --- (マニュアルの先頭
部分にある) 目次にざっと目を通したり、 (最後尾にある) 索引でお目当ての
関数やモジュール、用語を探すことだってできます。もしランダムな項目につ
いて勉強してみたいのなら、ランダムにページを選び ("random" 参照)、そこ
から 1, 2 節読むこともできます。このマニュアルの各節をどんな順番で読む
かに関わらず、 組み込み関数 の章から始めるとよいでしょう。マニュアルの
他の部分は、この節の内容について知っているものとして書かれているからで
す。

それでは、ショーの始まりです！


利用可能性について
==================

* 「利用できる環境 : Unix 」の意味はこの関数が Unix システムにあること
  が多いということです。このことは特定の OS における存在を主張するもの
  ではありません。

* If not separately noted, all functions that claim "Availability:
  Unix" are supported on macOS, which builds on a Unix core.

* If an availability note contains both a minimum Kernel version and a
  minimum libc version, then both conditions must hold. For example a
  feature with note *Availability: Linux >= 3.17 with glibc >= 2.27*
  requires both Linux 3.17 or newer and glibc 2.27 or newer.


WebAssemblyプラットフォーム
---------------------------

The WebAssembly platforms "wasm32-emscripten" (Emscripten) and
"wasm32-wasi" (WASI) provide a subset of POSIX APIs. WebAssembly
runtimes and browsers are sandboxed and have limited access to the
host and external resources. Any Python standard library module that
uses processes, threading, networking, signals, or other forms of
inter-process communication (IPC), is either not available or may not
work as on other Unix-like systems. File I/O, file system, and Unix
permission-related functions are restricted, too. Emscripten does not
permit blocking I/O. Other blocking operations like "sleep()" block
the browser event loop.

The properties and behavior of Python on WebAssembly platforms depend
on the Emscripten-SDK or WASI-SDK version, WASM runtimes (browser,
NodeJS, wasmtime), and Python build time flags. WebAssembly,
Emscripten, and WASI are evolving standards; some features like
networking may be supported in the future.

For Python in the browser, users should consider Pyodide or PyScript.
PyScript is built on top of Pyodide, which itself is built on top of
CPython and Emscripten. Pyodide provides access to browsers'
JavaScript and DOM APIs as well as limited networking capabilities
with JavaScript's "XMLHttpRequest" and "Fetch" APIs.

* Process-related APIs are not available or always fail with an error.
  That includes APIs that spawn new processes ("fork()", "execve()"),
  wait for processes ("waitpid()"), send signals ("kill()"), or
  otherwise interact with processes. The "subprocess" is importable
  but does not work.

* The "socket" module is available, but is limited and behaves
  differently from other platforms. On Emscripten, sockets are always
  non-blocking and require additional JavaScript code and helpers on
  the server to proxy TCP through WebSockets; see Emscripten
  Networking for more information. WASI snapshot preview 1 only
  permits sockets from an existing file descriptor.

* Some functions are stubs that either don't do anything and always
  return hardcoded values.

* Functions related to file descriptors, file permissions, file
  ownership, and links are limited and don't support some operations.
  For example, WASI does not permit symlinks with absolute file names.
