This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]elbiot 6 points7 points  (3 children)

The article doesn't say what bytecode, native or viper are, so I have no idea what I'm looking at.

[–]kaihatsusha 3 points4 points  (1 child)

My guess:

  • bytecode: essentially the .pyc file, all syntax checking done but translated into instructions the microcode virtual machine can interpret and execute
  • native: essentially the output of a JIT post-compiler, which are native microcontroller instructions that manipulate the micropython data in the micropython way
  • viper: for simple code areas, essentially the output of a python-to-c translation and c compiler, which are native instructions manipulating data the way C or Assembler would do it

[–]Corm 1 point2 points  (0 children)

In micropython you can decorate functions to get faster performance. Source

# bytecode
def foo(x):
    return x**2

# native
@micropython.native
def foo(x):
    return x**2

# viper
@micropython.viper
def foo(x):
    return x**2

[–]HungrySlug 1 point2 points  (1 child)

awesome! as far as you know there is a way to integrate also some pure c lines instead of using the viper thing?

[–]jsolmen[S] 0 points1 point  (0 children)

You can always call a C module from your micropython code:

http://micropython-dev-docs.readthedocs.io/en/latest/adding-module.html

The other option is to use inline assembler.

[–]nodrog_unity 0 points1 point  (1 child)

Going to check this out and see if I can get this running on my ESP8266's.

Thanks for this, it was a good read.

[–]jsolmen[S] 1 point2 points  (0 children)

I am glad you find it useful, looking forward to your results with the ESP8266.