Skip to content

Instantly share code, notes, and snippets.

@boxed
boxed / high_arity.py
Last active September 14, 2018 00:17
import os
from parso import parse
from collections import defaultdict
def get_arguments(i):
# parso represents functions with one argument and multiple arguments very differently, need to handle this here
if i.type == 'arglist':
return i.children
else:
@boxed
boxed / gist:f72221e7e77370be3e5703087c1ba54d
Created September 6, 2018 09:04
PEP???? Keyword only argument on function call
PEP:
Title: Keyword only argument on function call
Author: Anders Hovmöller <anders.hovmoller@trioptima.com>,
Johan Lübcke <johan.lubcke@trioptima.com>
Status: Active
Type: Process
Content-Type: text/x-rst
Created: 23-Aug-2018
Post-History: ???
@boxed
boxed / keyword_argument_analysis.py
Last active September 12, 2018 13:00
This tool analyses your code base for cases where a short for for keyword arguments would be nice to have
import os
from parso import parse
from collections import defaultdict
args = 0
kwargs = 0
kwargs_foo_equal_foo = 0
passed_value = 0
args_kwargs = 0
@boxed
boxed / timeIt.swift
Last active May 4, 2016 13:37 — forked from aschmied/timeIt.swift
Time code execution in Swift
import CoreFoundation
func timeIt(m: () -> ()) -> (Double, Int) {
let startTime = CFAbsoluteTimeGetCurrent()
var numberOfRuns = 0
while true {
m()
numberOfRuns += 1
let elapsed = CFAbsoluteTimeGetCurrent() - startTime
if elapsed > 0.5 { // we run the function up to 0.5 seconds, assuming here that we want to sample functions that are pretty fast