classes and object-oriented programming improve efficiencywithout worrying that the change will break code that uses the class some programming languages (java and ++for exampleprovide mechanisms for enforcing information hiding programmers can make the data attributes of class invisible to clients of the classand thus require that the data be accessed only through the object' methods sofor examplewe could get the idnum associated with rafael by executing rafael getidnum(but not by writing rafael idnum unfortunatelypython does not provide mechanisms for enforcing information hiding there is no way for the implementer of class to restrict access to the attributes of class instances for examplea client of person can write the expression rafael lastname rather than rafael getlastname(why is this unfortunatebecause the client code is relying upon something that is not part of the specification of personand is therefore subject to change if the implementation of person were changedfor example to extract the last name whenever it is requested rather than store it in an instance variablethen the client code would no longer work not only does python let programs read instance and class variables from outside the class definitionit also lets programs write these variables sofor examplethe code rafael birthday 'is perfectly legal this would lead to runtime type errorwere rafael getage invoked later in the computation it is even possible to create instance variables from outside the class definition for examplepython will not complain if the assignment statement me age rafael getage(occurs outside the class definition while this weak static semantic checking is flaw in pythonit is not fatal flaw disciplined programmer can simply follow the sensible rule of not directly accessing data attributes from outside the class in which they are definedas we do in this book generators perceived risk of information hiding is that preventing client programs from directly accessing critical data structures leads to an unacceptable loss of efficiency in the early days of data abstractionmany were concerned about the cost of introducing extraneous function/method calls modern compilation technology makes this concern moot more serious issue is that client programs will be forced to use inefficient algorithms consider the implementation of gradereport in figure the invocation of course getstudents creates and returns list of size nwhere is the number of students this is probably not problem for grade book for single classbut imagine keeping track of the grades of million high school students taking the sat' creating new list of that size when the list already exists is significant inefficiency one solution is to abandon the abstraction and allow gradereport to directly access the instance variable course studentsbut that would violate information hiding fortunatelythere is better solution