FAQ: Learn Python: Inheritance and Polymorphism - Overriding Methods

except i made some modifications, because we still need the User object for edit message.

you are making matters more complicated then they are. Of course we can:

class Message:
  def __init__(self, sender, recipient, text):
    self.sender = sender
    self.recipient = recipient
    self.text = text

class User:
  def __init__(self, username):
    self.username = username
    
  def edit_message(self, message, new_text):
    if message.sender == self.username:
      message.text = new_text

class Admin(User):
  def edit_message(self, message, new_text):
    message.text = new_text

test_text = 'This is test message!'             #define text for first message
test_text_002 = 'This is second test message!'  #define text for second message
edited_text = 'This is edited text'             #define text for edited message
user_001 = User('user_001@codecademy.com')      #define sender
user_002 = User('user_002@codecademy.com')      #define recipient
admin = Admin('admin')                          #define admin
first_message = Message(user_001.username,user_002.username,test_text)          #create first message 
user_001.edit_message(first_message, 'editing the message')
print(first_message.text)

If that is how you feel, you should write C or assembly code. Then python is too bloated. Python is a high-level language

I am going to be rude, sorry for that. But for me, working as a developer, these optimization you talk about are micro. They are not worth the time to optimize. You waste more time then you gain performance. Computers these days are so powerful

The reality is that if I had to write something like what you are currently doing, i would also use a relational database to make the data persist after the program has completed running. And then the choice would be simple many to one relations.

I know this is very likely not the answer you are looking for, sorry.