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.
Runs inlining in-place on an expression.
Arguments:
function factor{T<:Integer}(n::T) | |
0 < n || error("number to be factored must be positive") | |
h = Dict{T,Int}() | |
n == 1 && return h | |
local s::T, p::T | |
s = isqrt(n) | |
p = 2 | |
while p <= s | |
if n % p == 0 | |
while n % p == 0 |
function stress1(keys::Array{Int,1}) | |
x = Dict{Int,Float64}() | |
for i in keys | |
x[i] = 0.0 | |
end | |
return x | |
end | |
function stress_strings(n::Int) | |
d = Dict{String,Int}() |
function rd(f) | |
nr = countlines(f)::Int | |
fh = open(f) | |
nc = length(split(readline(fh),',')) | |
seekstart(fh) | |
d = Array(Float64, nr, nc) | |
temp = [0.0] | |
for i = 1:nr | |
l = readline(fh)::ASCIIString | |
idx = 1 |
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 } |
An array is a structure mapping indices to data values, where the indices have a particular structure.
An array can be thought of as a pair of an index set and a data set.
Two arrays are equal if they map the same indices to the same values.
An array is iterable, and when iterated generates exactly the values of
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 | |
[0K[33;1mWorker information[0m | |
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 | |
[0Ktravis_fold:start:system_info | |
[0K[33;1mBuild system information[0m |
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 |