Gurmeet Singh added the comment:
Please consider following before making a decision:
__
io.BufferedReader does not implement read1 (the last lines of trace
below)
It does. You made a mistake in your experiment (you called read1() on a FileIO
object, not a BufferedReader object).
Antoine Pitrou added the comment:
You called read1() on fl (a FileIO object) and not cfl (a BufferedReader
object). Your fault for choosing confusing variable names :-)
len(fl.read1(70934549))
Traceback (most recent call last):
File pyshell#44, line 1, in module
len(fl.read1(70934549))
Gurmeet Singh added the comment:
Please consider following before making a decision:
io.FileIO does not implements single OS system call on read() - instead
reads a file until EOF i.e. ignores the arguments supplied to read()
Your experiments show otherwise, the argument supplied to read()
Gurmeet Singh added the comment:
@Antoine - wait I will do it
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
___
___
Python-bugs-list
Gurmeet Singh added the comment:
@Antoine
It worked. I was wrong to say read1() was not implemented. Sorry.
But please do consider other issues.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
Antoine Pitrou added the comment:
If only one system call is being made, then I think that
fl.read(256) and fl.read(70934549) should take same amount of time to
complete - assuming disk I/O is the time consuming factor in this
operation (as compared to memory processing).
What do you mean?
Gurmeet Singh added the comment:
I did the following to understand time taken for in memory copy:
1 fl = io.FileIO('c:/temp9/Capability/Analyzing Data.mp4', 'rb')
2 byt = fl.read(70934549)
3 byt2 = None
4 byt2 = byt[:]
5 fl.close()
6 fl = io.FileIO('c:/temp9/Capability/Analyzing Data.mp4', 'rb')
Gurmeet Singh added the comment:
Sorry, typo in the last post - I meant in memory - memory copy not in place
memory copy.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
___
Antoine Pitrou added the comment:
Bytes objects are immutable, so trying to copy them doesn't copy anything
actually (it's an optimization):
b = bx *10
id(b)
139720033059920
b2 = b[:]
id(b2)
139720033059920
FileIO.read() only calls the underlying read() once, you can check the
Gurmeet Singh added the comment:
Thanks for letting me know about the optimization.
I trusted you that the system call is made once, though I looked up code to see
if size of the read in buffer is being passed to the C routine. I should
apologize though for raising this issue - since it is
Antoine Pitrou added the comment:
The time of line 7 was much greater than line 13.
Well, yes, reading 70 MB is much longer than reading a single byte :-)
I feel that the underlying system call takes the size argument
Indeed it does. It would be totally inefficient if it didn't.
so I
Antoine Pitrou added the comment:
Anyway, I'm now closing the issue as invalid.
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
components: +IO
nosy: +benjamin.peterson, hynek, pitrou, stutzbach
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
___
New submission from Gurmeet Singh:
1. The read mode is not the default mode as mentioned in the docs.python.org.
In particular see the first Traceback below - b does not work (as it does in
C though) and
you are forced to use rb instead.
2. io.BufferedReader does not implement read1 (the
Antoine Pitrou added the comment:
1. The read mode is not the default mode as mentioned in the
docs.python.org.
It is. If you don't mention a mode, the mode is r by default. But if you
mention a mode, then you are required to specify one of r, w, a.
io.BufferedReader does not implement
Changes by Amaury Forgeot d'Arc amaur...@gmail.com:
--
resolution: - invalid
status: open - pending
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17440
___
16 matches
Mail list logo