Re: [Python-Dev] Is file.readlines(sizehint=N) broken on 2.7?

2013-04-05 Thread INADA Naoki
The builtin open() was replaced with io.open().
It's difference between file.readlines() and io.IOBase.readlines().


On Sat, Apr 6, 2013 at 2:15 AM, Giampaolo Rodolà g.rod...@gmail.com wrote:

 with open('test-xxx', 'w') as f:
 f.write('aaa\nbbb\nccc')
 with open('test-xxx', 'r') as f:
 print(f.readlines(1))

 On Python 3.3 I get:

 ['aaa\n']

 ...while on Python 2.7:

 ['aaa\n', 'bbb\n', 'ccc']


 Is this a bug or I'm missing something?


 --- Giampaolo
 https://code.google.com/p/pyftpdlib/
 https://code.google.com/p/psutil/
 https://code.google.com/p/pysendfile/
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe:
 http://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com




-- 
INADA Naoki  songofaca...@gmail.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Is file.readlines(sizehint=N) broken on 2.7?

2013-04-05 Thread Giampaolo Rodolà
2013/4/5 INADA Naoki songofaca...@gmail.com:
 The builtin open() was replaced with io.open().
 It's difference between file.readlines() and io.IOBase.readlines().

Should that justify this difference in behavior?
Apparently on 2.X sizehint does not have any effect as far as I can see.

--- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Is file.readlines(sizehint=N) broken on 2.7?

2013-04-05 Thread Guido van Rossum
It's a *hint*, remember? :-) It does work, it's just rounded up to a
fairly large number in some implementations.

On Fri, Apr 5, 2013 at 11:24 AM, Giampaolo Rodolà g.rod...@gmail.com wrote:
 2013/4/5 INADA Naoki songofaca...@gmail.com:
 The builtin open() was replaced with io.open().
 It's difference between file.readlines() and io.IOBase.readlines().

 Should that justify this difference in behavior?
 Apparently on 2.X sizehint does not have any effect as far as I can see.

 --- Giampaolo
 https://code.google.com/p/pyftpdlib/
 https://code.google.com/p/psutil/
 https://code.google.com/p/pysendfile/
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/guido%40python.org



-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Is file.readlines(sizehint=N) broken on 2.7?

2013-04-05 Thread R. David Murray
On Fri, 05 Apr 2013 20:24:43 +0200, =?ISO-8859-1?Q?Giampaolo_Rodol=E0?= 
g.rod...@gmail.com wrote:
 2013/4/5 INADA Naoki songofaca...@gmail.com:
  The builtin open() was replaced with io.open().
  It's difference between file.readlines() and io.IOBase.readlines().
 
 Should that justify this difference in behavior?

Yes.  The 'file' documentation for readlines says documents that the
argument is advisory and may be rounded up to an internal buffer size.

io's readlines, on the other hand, says no more lines will be read if
the total size of bytes read so far exceeds the hint.

So, different semantics.

 Apparently on 2.X sizehint does not have any effect as far as I can see.

Have you played with large enough hints/small enough buffers?

--David

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Is file.readlines(sizehint=N) broken on 2.7?

2013-04-05 Thread Giampaolo Rodolà
2013/4/5 R. David Murray rdmur...@bitdance.com:
 On Fri, 05 Apr 2013 20:24:43 +0200, =?ISO-8859-1?Q?Giampaolo_Rodol=E0?= 
 g.rod...@gmail.com wrote:
 2013/4/5 INADA Naoki songofaca...@gmail.com:
  The builtin open() was replaced with io.open().
  It's difference between file.readlines() and io.IOBase.readlines().

 Should that justify this difference in behavior?

 Yes.  The 'file' documentation for readlines says documents that the
 argument is advisory and may be rounded up to an internal buffer size.

 io's readlines, on the other hand, says no more lines will be read if
 the total size of bytes read so far exceeds the hint.

 So, different semantics.

I see.

 Apparently on 2.X sizehint does not have any effect as far as I can see.

 Have you played with large enough hints/small enough buffers?

Right, it seems it tends to change around 8196 bytes.
Ok then, nevermind.


--- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com