LoginSignup
31
12

More than 5 years have passed since last update.

Python 1.0 をビルドする

Last updated at Posted at 2017-01-11

ちょっとした考古学的興味により初期のPythonを調べてみたくなったので、Python 1.0.1 をビルドして動かしてみた。

プログラミング考古学シリーズ

ソースコード入手

現在Pythonの公式ページから手に入る最も古いソースコードは、Python 1.0.1 である。これはPythonの開発が始まった1989年12月からすでに5年近く経過した1994年にリリースされたものである。READMEによると、

Older sources

If you find an older Python release (e.g. 0.9.8), we're interested
in getting a copy! webmaster@python.org

とあるので、これ以前のバージョンはデータが失われてしまったものと思われる。1989年といえばGitもSVNもCVSもなかった時代なので致し方なし。

ダウンロードして解凍する。

$ curl http://legacy.python.org/download/releases/src/python1.0.1.tar.gz -O
$ tar xzf python1.0.1.tar.gz
$ cd python-1.0.1

ビルド

tarballの中にはconfigureMakefile.inなどが入っており、ビルド手順は現代と全く変わらない。

ただし、内部で使われている関数getlineが現代の標準ライブラリと衝突するので、名前を置き換えてやる必要がある。

$ sed -i 's/^getline/my_getline/' Objects/fileobject.c
$ sed -i 's/ getline/ my_getline/' Objects/fileobject.c

あとはいつも通りにビルドすればOK。

$ ./configure
$ make

動かしてみる

出てきたバイナリファイルpythonで適当に遊んでみる。

$ ./python
Python 1.0.1 (Jan 11 2017)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> hex(12345678901234567890)
OverflowError: integer literal too large
>>> hex(12345678901234567890L)
'0xAB54A98CEB1F0AD2L'
>>> int('100')
Traceback (innermost last):
  File "<stdin>", line 1
TypeError: int() argument can't be converted to int
>>> int(1.5)
1
>>> def fibonatti(n):
...     if n == 1 or n == 2:
...         return 1
...     else:
...         return fibonatti(n - 1) + fibonatti(n - 2)
...
>>> fibonatti(5)
5
>>> o = {'foo': 1, 'bar': 'baz'}
>>> o
{'foo': 1, 'bar': 'baz'}
>>> for i in range(5):
...     print(i)
...
0
1
2
3
4
>>> range(100)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
>>> [i * 2 for i in range(10)]
/home/esolang/python: line 3:     7 Segmentation fault      ./python
$

だいぶ機能は足りないが、現代のPythonとほぼ同じように使える。

次回

Ruby 0.49 をビルドする - Qiita

参考文献

31
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
12