Skip to content

Instantly share code, notes, and snippets.

View JeffBezanson's full-sized avatar

Jeff Bezanson JeffBezanson

View GitHub Profile
@JeffBezanson
JeffBezanson / gist:4212658
Created December 5, 2012 05:38
add ProcessEachLine
diff --git a/base/process.jl b/base/process.jl
index e8fadae..74a8914 100644
--- a/base/process.jl
+++ b/base/process.jl
@@ -677,11 +677,27 @@ end
readall(ports::Ports) = _readall(ports, cmds(ports))
readall(cmds::Cmds) = _readall(stdout(cmds), cmds)
+type ProcessEachLine
+ stream::IO
@JeffBezanson
JeffBezanson / gist:5325156
Created April 6, 2013 06:45
emacs input method for unicode technical symbol input
(quail-define-package
"symbol-input" "unicode" "unicode-sym" t
"Easier input for unicode technical symbols"
nil t nil nil nil nil nil nil nil nil t)
(quail-define-rules
("\\alpha" ?α)
("\\beta" ?β)
("\\gamma" ?γ)
("\\delta" ?δ)
@JeffBezanson
JeffBezanson / inlining.md
Last active January 14, 2016 22:03
how to invoke julia inlining passes

Here is a description and demo of the relevant functions.

StaticVarInfo is the state object used to track local variable and other context information during inference and other passes.

inlining_pass

Runs inlining in-place on an expression.

Arguments:

@JeffBezanson
JeffBezanson / symbol-input.el
Created January 17, 2014 20:26
emacs symbol input mode
(quail-define-package
"symbol-input" "unicode" "unicode-sym" t
"Easier input for unicode technical symbols"
nil t nil nil nil nil nil nil nil nil t)
(quail-define-rules
("\\alpha" ?α)
("\\beta" ?β)
("\\gamma" ?γ)
("\\delta" ?δ)
Faster version:
julia> code_llvm(STDOUT, Base._unsafe_getindex, Tuple{typeof(Base.linearindexing(a)), typeof(a), typeof(r), typeof(1)}, false, true)
; ModuleID = '_unsafe_getindex'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%jl_value_t = type { %jl_value_t* }
%OneTo = type { i64 }
import Base: endof, sizeof, pointer, next
using Base: UTF_ERR_INVALID_INDEX, is_valid_continuation, utf8_trailing, utf8_offset
type Str <: AbstractString
len::Int
function Str(p::Union{Ptr{Int8},Ptr{UInt8}}, n::Integer)
s = ccall(:jl_gc_allocobj, Any, (Csize_t,), n+sizeof(Int))
ps = pointer_from_objref(s)
unsafe_store!(convert(Ptr{Ptr{Void}}, ps), pointer_from_objref(Str), 0)
unsafe_store!(convert(Ptr{Int}, ps), n)
INFO: Installing Example v0.4.0
INFO: Package database updated
INFO: METADATA is out-of-date — you may not have the latest version of Example
INFO: Use `Pkg.update()` to get the latest versions of your packages
INFO: Initializing package repository /tmp/o8xgwvMS/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
INFO: No packages to install, update or remove
INFO: Cloning cache of Example from https://github.com/JuliaLang/Example.jl.git
INFO: Installing Example v0.4.1
INFO: Package database updated
travis_fold:start:worker_info
Worker information
hostname: wjb-1.macstadium-us-se-1.travisci.net:fbee6be9-3545-4d4b-98ad-d0fb4f031325
version: v2.6.2 https://github.com/travis-ci/worker/tree/fdccca4efd347ebc889baae641ccbf55bb871d19
instance: a349cd59-a02e-46c9-8c28-ece0f707dfc7:travis-ci-osx10.11-xcode8-1479248015
startup: 1m54.291250744s
travis_fold:end:worker_info
travis_fold:start:system_info
Build system information
immutable Myo{C}
c::C
function (::Type{Myo{C}}){C}(c)
if 2 == 2 # expansion of @assert 2==2
nothing
else
throw(Base.AssertionError("2 == 2"))
end
return new{C}(c)
end
diff --git a/base/iterators.jl b/base/iterators.jl
index 1c2ab13..4e5d1b5 100644
--- a/base/iterators.jl
+++ b/base/iterators.jl
@@ -694,28 +694,30 @@ function start(f::Flatten)
d = done(f.it, s)
# this is a simple way to make this function type stable
d && throw(ArgumentError("argument to Flatten must contain at least one iterator"))
+ done_inner = false
while !d