Red Hat Bugzilla – Bug 199932
japanese module automatically imports itself
Last modified: 2007-11-30 17:11:38 EST
Description of problem:
Fedora's 'python-2.4.2-3.2.1' rpm contains the standard Python software plus
the third-party module 'japanese'.
The file /usr/lib/python2.4/site-packages/japanese.pth contains
This causes lots of Japanese language-specific code to be executed at
the beginning of EVERY python program.
[ 'import japanese' causes python to read
which causes python to execute 'import aliases'
which causes python to read
which causes python to execure 'import encodings.aliases' ... ]
Its good that Python has Japanese language support, but I don't think that
Japanese language code needs to be executed by default for every Python
program. It causes a performance penalty for the large number of Python users
who do not require Japanese language support.
1) Remove the japanese.pth file so that the Japanese codecs are disabled by
default. Then a Python user can 'import japanese' if and when its required.
Either by adding 'import japanese' at the top of a script
or by editing /usr/lib/python2.4/site.py (or sitecustomize.py) and adding
'import japanese' so it is executed for all Python programs.
2) Remove the japanese module from the Fedora 'python-2.4.2-3.2.1' rpm
and create a 'python-japanese' rpm which is no longer installed with Python,
but instead becomes an optional extra package (perhaps installed if a Japanese
locale is selected).
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create a minimal python script 'test.py':
2. $ strace ./test.py >strace-log 2>&1
3. Search through the log file for 'japanese' and 'encodings' to see all the
extra system calls that are made.
Many system calls involve 'japanese' and 'encodings'.
No system calls to 'japanese' and 'encodings' unless the Python programmer
explicitly imports the japanese module.
I agree, I like the second one beter (splitting japanese out).
japanese pulled out from python 2.5 packaging; if someone still needs the
functionality, they can submit it as a separate package