Python Forum
Do objects get their own copy of the class methods?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do objects get their own copy of the class methods?
#1
Hi,

Platform: Windows 10
Python version: 3.7

I came across a video on YouTube which suggested that objects

in Python get their own copies of the class methods.

If this is true then programs in Python must use a lot of memory.

The code below was an attempt to print the ids of the two methods.

The result was that both methods had the same id.

Would appreciate some clarification on this issue.

Thanks in advance for any help.

class Testing:
    def print_me(self):        
        print(id(self.print_me))
        
    def print_me2(self):        
        print(id(self.print_me2))
        
myTest = Testing()
myTest.print_me()
myTest.print_me2() 
Reply


Messages In This Thread
Do objects get their own copy of the class methods? - by Charles1 - Feb-02-2019, 03:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 310 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Class test : good way to split methods into several files paul18fr 4 535 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  How can I access objects or widgets from one class in another class? Konstantin23 3 1,070 Aug-05-2023, 08:13 PM
Last Post: Konstantin23
  Structuring a large class: privite vs public methods 6hearts 3 1,126 May-05-2023, 10:06 AM
Last Post: Gribouillis
  access share attributed among several class methods drSlump 0 1,082 Nov-18-2021, 03:02 PM
Last Post: drSlump
  a function common to methods of a class Skaperen 7 2,685 Oct-04-2021, 07:07 PM
Last Post: Skaperen
  Listing All Methods Of Associated With A Class JoeDainton123 3 2,390 May-10-2021, 01:46 AM
Last Post: deanhystad
  too many methods in class - redesign idea? Phaze90 3 2,531 Mar-05-2021, 09:01 PM
Last Post: deanhystad
  Special Methods in Class Nikhil 3 2,333 Mar-04-2021, 06:25 PM
Last Post: Nikhil
  cant able to make methods interact with each other in the class jagasrik 2 1,833 Sep-16-2020, 06:52 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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