What is the time complexity in Big O notation of Python3's open() function when appending to a file?
For example, the following line: with open("HugeDocument.csv", "a") as f
Based on my understanding the open() function returns a file object which is a pointer/handle to the actual resource on the disk. Hence the complexity of open() should be constant, since the location of the file is passed into the open(file='abc') function.
https://docs.python.org/3/glossary.html#term-file-object
An object exposing a file-oriented API (with methods such as read() or write()) to an underlying resource. Depending on the way it was created, a file object can mediate access to a real on-disk file or to another type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc.).
Performing operations using the file object will have different complexity depending on the type of operation (like read(), readline(), seek()), the file size, system memory limits and other File System configurations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With