GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Yet Another Python Internals Blog
  • About
  • Dynamic typing (part 1)
  • lpoulain
  • bytecode
  • Python
  • Everything’s an object
  • On immutability
  • Python bytecode

This view

  • Original page
  • New address

GeezerVison is showing pythoninternal.wordpress.com — bytecode – Yet Another Python Internals Blog

Python is a dynamically-typed language, just like PHP, JavaScript or Ruby, and contrary to statically-typed languages such as C/C++, Java or Scala.

In a dynamically-typed language, the code can never know in advance what will be the type of any variable. You can define a function to perform a particular operation on, say, a collection, but unless you explicitly filter out an argument that is not a collection, the code is never certain that it is indeed one – and the bytecode compiler sure cannot be certain either.

Using dynamic types has consequences for the language – both from a conceptual standpoint and from an implementation standpoint.
Continue reading →

In Python, pretty much everything is an object, whether it is a number, a function… or even None.
Continue reading →

An immutable structure is a structure that does not change once it has been created. If the concept is nothing new, it has been used more and more for its upsides. Let’s review how Python handles immutability.
Continue reading →

Just like Java or C#, CPython is compiling the code into bytecode which is then interpreted by a virtual machine. The Python library dis allows to disassemble Python code and to see how are things are compiled under the hood. Consider the following code:

>>> def test():
...     for i in range(10):
...             print(i)
...

You can call dis.dis(test) to display the compiled bytecode, and dis.show_code(test) to understand the symbols referenced by that bytecode. Continue reading →

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.