Movatterモバイル変換
[0]ホーム
[Python-Dev] xreadlines : readlines :: xrange : range
Guido van Rossumguido@python.org
Thu, 04 Jan 2001 09:16:39 -0500
[Thomas finds that on FreeBSD, getc() is faster than getc_unlocked().]Thomas, I really don't understand it. The getc() source code youshowed calls getc_unlocked(). So how can it be faster? The answermust be somewhere else... Cache line conflicts, the rewriting of theloop that I did, a compiler bug, the inlining, who knows. Can youcompare the generated assembly code? On other platforms,getc_unlocked() typically speeds the readline() test case up by asignificant factor (as in your BSDI numbers, where it's almost 3xfaster).Could it be that you're mistaken and that somehow getc_unlocked() is*not* chosen on FreeBSD? Then I could believe it, the rewritten loopis so different that the optimizer might have done something differentto it. (Check config.h. When all else fails, I put an #error in the#ifdef branch that I expect not to be taken.)Could it be that somehow getc_unlocked() is later defined to be thesame as getc(), so choosing it just adds the overhead of callingf[un]lockfile() for each line?--Guido van Rossum (home page:http://www.python.org/~guido/)
[8]ページ先頭