I am using exchangelib to fetch emails. My function retrieves nearly 150000 emails(output is of type query set) in a second. I have to convert query set into JSON array for processing it further. Right now it is taking about an hour to convert QuerySet obj into JSON array, I want this conversion to happen in seconds though.
Sample code :
MailsArray = []
query_filter = Q(sender=xyz@abc.com)
timeLimit = UTC_NOW() - timedelta(hours=1)
# This step returns data in seconds
Inbox_mails = account.inbox.all().filter(query_filter,datetime_received_gt=timeLimit).only('subject','sender','conversation_id')
# This step takes a lot of time
for x in Inbox_mails:
MailsArray.append( {"Subject":x.subject,"ID":x.conversation_id.id})
Any ideas on converting QuerySet data into JSON array fastly would be appreciated