Bug 199932 - japanese module automatically imports itself
japanese module automatically imports itself
Product: Fedora
Classification: Fedora
Component: python (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeremy Katz
Brock Organ
Depends On:
  Show dependency treegraph
Reported: 2006-07-24 09:30 EDT by Steve Chaplin
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-01-06 16:23:41 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Steve Chaplin 2006-07-24 09:30:32 EDT
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
  'import japanese'
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.

Possible solutions:
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):

How reproducible:

Steps to Reproduce:
1. Create a minimal python script 'test.py':
#!/usr/bin/env python
print 'a'

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.
Actual results:
Many system calls involve 'japanese' and 'encodings'.

Expected results:
No system calls to 'japanese' and 'encodings' unless the Python programmer
explicitly imports the japanese module.

Additional info:
Comment 1 Mihai Ibanescu 2006-07-24 09:56:43 EDT
I agree, I like the second one beter (splitting japanese out).
Comment 2 Jeremy Katz 2007-01-06 16:23:41 EST
japanese pulled out from python 2.5 packaging; if someone still needs the
functionality, they can submit it as a separate package

Note You need to log in before you can comment on or make changes to this bug.