Python name | Python meaning | Julia name | Julia meaning |
---|---|---|---|
def f(x,y): |
named function - duck-typing, no polymorphism | fuction f(x,y) |
duck-typing, multiple dispatch to methods |
lambda x: x |
anonymous function | (x) -> x |
anonymous function |
class MyClass(Parent) |
classical OOP class, multiple inheritance | struct MyStruct{TypeParameters} <: AbstractParent |
data and constructor only, types inside struct can be parametrized, can inherit only from abstract types |
def __init__(self, x): |
constructor of a class, one per class | MyStruct(x) (outer constructor), MyStruct(x) = new(x) (inner constructor) |
Constructor method (multiple constructors can be defined, selected using multiple dispatch) |
method | function that belongs to a class (single dispatch on first argument self ) |
method | function implementation for concete parameter types (multiple dispatch on all arguments) |
a = MyClass(x), x.func(y) |
Creating an object, calling a method de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
using PyCall | |
using DataFrames | |
using CSV | |
py"""import timeit | |
import numpy as np""" | |
py"""def py_time(f, number=1_000): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.12.17 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local el = $(esc(element)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.12.11 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local el = $(esc(element)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.12.10 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local el = $(esc(element)) |