Archives mensuelles : février 2023

Analyse memory in Python

Main metrics – identify python file/functions consuming most memory:It is very reliable to detect rise/peak memory. Generally it is computed by a comparison of the process rss of before and after the execution of python code/function. – Number of objects … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

inspect in python

How to check if an object start with a specific package: module = inspect.getmodule(o) is_foo_app: bool = False if module and module.__name__: if module.__name__.split(’.’)[0] == "foo_app": is_foo_app = True Retrieve all members of an object: getmembers: list[tuple[str, Any]] = inspect.getmembers(foo_object) … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Python: module with submodules

Run a program containing submodules Assume we have the following layout: – module_with_sub_module: the directory that contains the application(It is not the base module directory but a directory that holds it ). – foo/app: a submodule – foo/business: a submodule … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Python docstring

Main docstring formats In Python, they are multiple docstring formats. There is an official format: reStructuredText but there are also not official but very used formats. – reStructuredText: Official Python documentation standard. It has many features but it is also … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

CDK python examples

Basic infrastructure that defines  initial configuration, connections, key name to grant SSH access and use a static elastic IP import aws_cdk.aws_ec2 as ec2 # import aws_cdk.aws_ec2.Port as Port import aws_cdk.aws_iam as iam from aws_cdk import ( # Duration, Stack, Duration, # aws_sqs … Continuer la lecture

Publié dans Non classé | Laisser un commentaire