Bug 199932 - japanese module automatically imports itself
Summary: japanese module automatically imports itself
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeremy Katz
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-24 13:30 UTC by Steve
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2007-01-06 21:23:41 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Steve 2006-07-24 13:30:32 UTC
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
  /usr/lib/python2.4/site-packages/japanese/__init__.py
  which causes python to execute 'import aliases'
  which causes python to read
  /usr/lib/python2.4/site-packages/japanese/aliases/__init__.py
  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):
python-2.4.2-3.2.1

How reproducible:
Always

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 13:56:43 UTC
I agree, I like the second one beter (splitting japanese out).

Comment 2 Jeremy Katz 2007-01-06 21:23:41 UTC
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.