Category Archives: Momentos

The dis Module: A Quick and Easy Way to Analyze Python Code Performance

The dis module in Python provides a way to disassemble Python bytecode. This can be useful for a variety of tasks, such as:

  • Debugging: The dis module can be used to step through Python bytecode line by line, which can be helpful for debugging Python programs.
  • Performance analysis: The dis module can be used to analyze the performance of Python programs by looking at the bytecode instructions that are being executed.
  • Code optimization: The dis module can be used to optimize Python code by identifying inefficient bytecode instructions and rewriting them to be more efficient.
  • Reverse engineering: The dis module can be used to reverse engineer Python code by disassembling it and reconstructing the original source code.

You can get the bytecode portion of your code calling dis function:

import dis

dis.dis("print('Hello, world!')")

This code will print the following output:

2           0 LOAD_CONST               0 ('Hello, world!')
            3 PRINT_ITEM
            4 PRINT_NEWLINE
            5 LOAD_CONST               0 (None)
            8 RETURN_VALUE

You can use this to compare different ways to write code in python and there corresponding bytecode.

dis.dis("a = dict()")

This code will print the following bytecode:

1           0 LOAD_NAME                0 (dict)
            2 CALL_FUNCTION            0
            4 STORE_NAME               1 (a)
            6 LOAD_CONST               0 (None)
            8 RETURN_VALUE

If you, instead write the code:

dis.dis("a = {}")

Will print the bytecode:

1           0 BUILD_MAP                0
            2 STORE_NAME               0 (a)
            4 LOAD_CONST               0 (None)
            6 RETURN_VALUE

Notice the later approach as less instructions by not having to run CALL_FUNCTION

The dis module is a powerful tool that can help you to improve the performance of your Python code. It can help you to identify inefficient bytecode instructions, understand the flow of your code, debug your code, and reverse engineer Python code.

The dis module is a valuable tool for Python developers who want to improve the performance of their code. By understanding how the dis module works, developers can identify inefficient bytecode instructions and rewrite their code to improve performance. Additionally, the dis module can be used to debug code, understand the flow of code, and reverse engineer Python code.

El smartphone nos está haciendo más estúpidos

…menos inteligentes
Esto ya lo suponíamos, solo que ahora salió la evidencia científica que lo confirma. Estar al pendiente de las notificaciones o el simple hecho de tener el celular cerca preguntándose en que momento llegará la siguiente distracción mantiene nuestro cerebro alejado de las tareas importantes, del razonamiento analítico aplicado a la resolución de problemas.

https://lifehacker.com/your-smartphone-is-making-you-stupid-1796449887

Wacom Intuos Pen Tablet Comparison

I recently started using my Intuos pen tablet again as an alternative to the mouse and to avoid wrist pain.

Draw Art Photo Comic 3D
Size small small/medium small medium
ExpressKeys 4
Multi-touch No Yes
Pressure levels 1024
Wireless Yes, sold separatly
Software ArtRage Lite Corel Painter Essentials 5 Corel® PaintShop® Pro X8 (Windows) Corel® Aftershot® Pro 2 (Mac)  Clip Studio Paint Pro and Anime Studio® Debut 10 ZBrushCore®