[issue11114] file.tell extremely slow

2011-02-04 Thread Laurens

New submission from Laurens 3.14159265...@xs4all.nl:

file.tell() has become extremely slow in version 3.2, both rc1 and rc2. This 
problem did not exist in version 2.7.1, nor in version 3.1. It could be 
reproduced both on mac and windows xp.

--
components: IO
messages: 127874
nosy: Laurens
priority: normal
severity: normal
status: open
title: file.tell extremely slow
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

Do you have a benchmark program you can post?

--
nosy: +eric.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread Laurens

Laurens 3.14159265...@xs4all.nl added the comment:

Correction: the problem also exists in version 3.1. I created a benchmark 
program an ran it on my machine (iMac, snow leopard 10.6), with the following 
results:

--
2.6.6 (r266:84292, Dec 30 2010, 09:20:14) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 0.0009 s.
--
2.7.1 (r271:86832, Jan 13 2011, 07:38:03) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 0.0008 s.
--
3.1.3 (r313:86882M, Nov 30 2010, 09:55:56) 
[GCC 4.0.1 (Apple Inc. build 5494)]
result: 9.5682 s.
--
3.2rc2 (r32rc2:88269, Jan 30 2011, 14:30:28) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 8.3531 s.

Removing the line containing tell gives the following results:

--
2.6.6 (r266:84292, Dec 30 2010, 09:20:14) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 0.0007 s.
--
2.7.1 (r271:86832, Jan 13 2011, 07:38:03) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 0.0006 s.
--
3.1.3 (r313:86882M, Nov 30 2010, 09:55:56) 
[GCC 4.0.1 (Apple Inc. build 5494)]
result: 0.0093 s.
--
3.2rc2 (r32rc2:88269, Jan 30 2011, 14:30:28) 
[GCC 4.2.1 (Apple Inc. build 5664)]
result: 0.0007 s.


(Apparently, reading a file became a lot faster from 3.1 to 3.2.)

Conclusion: Execution of file.tell() makes the program about 1 times slower.

Remark: the file mdutch.txt is a dummy text file containing 1000 lines with one 
word on each line.

--
Added file: http://bugs.python.org/file20674/tell v01.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

I found that adding infile._CHUNK_SIZE = 20 makes the test much faster - 
'only' 5 times slower than 2.7.

--
nosy: +amaury.forgeotdarc, pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread DSM

DSM dsm...@users.sourceforge.net added the comment:

With a similar setup (OS X 10.6) I see the same problem.  It seems to go away 
if the file is opened in binary mode for reading.  @Laurens, can you confirm?

--
nosy: +dsm001

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread DSM

DSM dsm...@users.sourceforge.net added the comment:

(By go away I mean stop being pathological, not stop differing: I still 
see a factor of 2.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11114] file.tell extremely slow

2011-02-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

That's expected. seek() and tell() on text (unicode) files are slow by 
construction. You should open your file in binary mode instead, if you want to 
do any seeking.

Maybe I should add a note in 
http://docs.python.org/dev/library/io.html#performance

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com