Skip to content

Instantly share code, notes, and snippets.

@lungben
lungben / Python Interoperability.jl
Created Nov 16, 2020
A Pluto.jl notebook illustrating the interoperability of Julia and Python
View Python Interoperability.jl
### 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))
View NumpyJuliaPerformance.jl
using BenchmarkTools
using PyCall
using DataFrames
using CSV
py"""import timeit
import numpy as np"""
py"""def py_time(f, number=1_000):
@lungben
lungben / mandelbrot.jl
Created Dec 26, 2020
Mandelbrot with Pluto.jl
View mandelbrot.jl
### 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))
View table_benchmarks.jl
### 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))
@lungben
lungben / python_julia_comparison.md
Last active Mar 21, 2020
Comparison of Julia and Python
View python_julia_comparison.md

Comparison of Julia and Python

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