Python Forum
Performance degradation with IO class inheritance
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Performance degradation with IO class inheritance
#1
Hi all!

I recently tried to build a new IO class from python built-in IO classes. I noticed some performance degradation for these new classes. I wondering if anyone knows what might be the possible cause/fix for this.

from _io import FileIO, BufferedReader

class FileIO_new(FileIO): ()
class BufferedReader_new(BufferedReader): ()

def built_in_io():
    # a 3.5 MB file
    raw = FileIO('filename', 'r')
    buffer = BufferedReader(raw)
    lines = buffer.readlines()
    buffer.close()
def new_io():
    raw = FileIO_new('filenmae','r')
    buffer = BufferedReader_new(raw)
    lines = buffer.readlines()
    buffer.close()

>>>%timeit built_in_io()
1.79 ms ± 14.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
>>>%timeit new_io()
5.25 ms ± 87 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Reply


Messages In This Thread
Performance degradation with IO class inheritance - by wsygzyx - Jun-17-2020, 12:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  super() and order of running method in class inheritance akbarza 7 815 Feb-04-2024, 09:35 AM
Last Post: Gribouillis
  Child class inheritance issue eakanathan 3 1,362 Apr-21-2022, 12:03 PM
Last Post: deanhystad
  Importing issues with base class for inheritance riccardoob 5 4,748 May-19-2021, 05:18 PM
Last Post: snippsat
  3D vector class with inheritance from 2D vector class buss0140 4 3,178 Dec-20-2020, 08:44 PM
Last Post: deanhystad
  Class inheritance oclmedyb 3 2,281 Dec-09-2020, 04:43 PM
Last Post: deanhystad
  Can we access instance variable of parent class in child class using inheritance akdube 3 14,024 Nov-13-2020, 03:43 AM
Last Post: SalsaBeanDip
  performance kerzol81 1 1,927 Oct-07-2019, 10:19 AM
Last Post: buran
  Confusion with sublcassing a threading class, and inheritance bigmit37 2 7,702 Apr-08-2019, 09:28 AM
Last Post: DeaD_EyE
  Class Attributes Inheritance Harry_Potter 3 3,873 Nov-16-2017, 07:01 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020