Have you ever had to write a method that takes an iterable container (list, set, etc) and have to perform operations over it to return another iterable container as output? If yes, then python generators might be the first optimization tool you should look into.

Image for post
Image for post

What are python generators?
Generators are iterators, but you can only iterate over them once. It’s because they do not store all the values in memory, they generate the values on the fly. …


Image for post
Image for post

How does Linux do memory management to execute your processes is a little complicated thing to explain. But luckily all the abstracted details around memory management like memory allocation and context switching b/w processes are very well optimized and developers don’t have to worry about these things while writing high-level code.


If you are looking for a quick but scalable way to get a scheduling service up and running for a task, APScheduler might just be the trick you are looking for.

from flask import Flask, request
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime
schedule_app = Flask(__name__)

# initialize scheduler with your preferred timezone
scheduler = BackgroundScheduler({'apscheduler.timezone': 'Asia/Calcutta'})
scheduler.start()



@schedule_app.route('/schedulePrint', methods=['POST'])
def schedule_to_print():
data = request.get_json()
#get time to schedule and text to print from the json
time = data.get('time')
text = data.get('text')
#convert to datetime
date_time = datetime.strptime(str(time), …

About

Chetan Mishra

An enthusiastic learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store