I need to deal with some data that, in most cases, do not need to be written to disk. I'm using SQLAlchemy to deal with database operations. These data are from json strings. For example,
from sqlalchemy import String, Column
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Class1(Base):
__tablename__ = 'table'
data = Column(String)
#and some other data members
@staticmethod
def parse(json_):
#parse the json and return a list of Class1 instances
class Class2():
__init__(self, data):
self.data = data
#and some other data members
@staticmethod
def parse(json_):
#parse the json and return a list of Class2 instances
Basically, these two class are the same except that Class1 can deal with database and Class2 cannot. Is there any performance difference between the two class when
- Create instances from json,
- Normal operations such as read data from a instance?
If there are performance difference, is there a good solution that can eliminate it while keeping DRY?