Carlos Daniel Ruvalcaba Valenzuela wrote: > Don't worry too much for the accessors, I'm pretty sure it won't > degrade your performance in a noticeable way, you objects will only > grow a tiny bit by adding a function to the class, all objects share > the same in memory code and each one has it's own data, the function > for the object is just a reference for the class function, not the > memory of the function itself (I think, it would be a waste of memory > otherwise). > > However take it with a grain of salt, do your own benchmarks, you > could do a simple measure with time.time() function, or use one of the > several profiling modules for python (profile, hotshot, etc). > > Forwarded to Tutor list, I forgot it sorry! > > Regards, > Carlos Daniel Ruvalcaba Valenzuela > > On 9/16/07, Jeff Peery <[EMAIL PROTECTED]> wrote: >> Hello, >> I've got a quick question regarding performance of lists. I am taking >> measurements and building up a list of objects for each measurement. the >> class I created for the objects has attributes of time, numerical value, >> person's name who collected the sample etc. I also have functions within my >> class (I think they are properly named 'accessors'?) that get a piece of >> data within the object, for example 'self.GetSampleTime()'. I'm wondering >> what happens to my performance as I add more accesors to my class. How are >> the accesors managed? will each object in my list of objects contain the >> data for each accesor or do all the objects look to the sample module for >> the accesor? will my list of objects become huge and slow as I add more >> accessors? thanks. >>
AFAIK accessors are not recommended in Python, your attributes can not be hidden anyway (only by convention). Just access or set the attributes directly : myClass.myAttribute = someValue. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor