All Projects → c42f → FastClosures.jl

c42f / FastClosures.jl

Licence: other
Faster closure variable capture

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to FastClosures.jl

GlobalSensitivity.jl
Robust, Fast, and Parallel Global Sensitivity Analysis (GSA) in Julia
Stars: ✭ 30 (-23.08%)
Mutual labels:  julialang
DynamicalBilliards.jl
An easy-to-use, modular, extendable and absurdly fast Julia package for dynamical billiards in two dimensions.
Stars: ✭ 97 (+148.72%)
Mutual labels:  julialang
learn-swift-with-bob
Learn Swift 4 with Bob: Intermediate to Advanced Swift 4 Course
Stars: ✭ 22 (-43.59%)
Mutual labels:  closures
wdio-automation
Functional test automation with wdio + page objects + selenium standalone + docker
Stars: ✭ 24 (-38.46%)
Mutual labels:  closures
PWDFT.jl
Plane wave density functional theory using Julia programming language
Stars: ✭ 86 (+120.51%)
Mutual labels:  julialang
ISLR.jl
JuliaLang version of "An Introduction to Statistical Learning: With Applications in R"
Stars: ✭ 135 (+246.15%)
Mutual labels:  julialang
Closures
Swifty closures for UIKit and Foundation
Stars: ✭ 1,720 (+4310.26%)
Mutual labels:  closures
SpinMonteCarlo.jl
Markov chain Monte Carlo solver for lattice spin systems implemented by Julialang
Stars: ✭ 35 (-10.26%)
Mutual labels:  julialang
DataAPI.jl
A data-focused namespace for packages to share functions
Stars: ✭ 29 (-25.64%)
Mutual labels:  julialang
IterTools.jl
Common functional iterator patterns
Stars: ✭ 124 (+217.95%)
Mutual labels:  julialang
Intervals.jl
Non-iterable ranges
Stars: ✭ 29 (-25.64%)
Mutual labels:  julialang
graphics
A place where miscellaneous Julia-related graphics are stored. If you're looking for the official Julia logos and related graphics, visit https://github.com/juliaLang/julia-logo-graphics.
Stars: ✭ 16 (-58.97%)
Mutual labels:  julialang
SeaPearl.jl
Julia hybrid constraint programming solver enhanced by a reinforcement learning driven search.
Stars: ✭ 119 (+205.13%)
Mutual labels:  julialang
DataFrames
Welcome to DataFrames.jl with Bogumił Kamiński
Stars: ✭ 106 (+171.79%)
Mutual labels:  julialang
benchopt
Making your benchmark of optimization algorithms simple and open
Stars: ✭ 89 (+128.21%)
Mutual labels:  julialang
You Dont Know Js
A book series on JavaScript. @YDKJS on twitter.
Stars: ✭ 147,493 (+378087.18%)
Mutual labels:  closures
SortingLab.jl
Faster sorting algorithms (sort and sortperm) for Julia
Stars: ✭ 20 (-48.72%)
Mutual labels:  julialang
Scientific-Programming-in-Julia
Repository for B0M36SPJ
Stars: ✭ 32 (-17.95%)
Mutual labels:  julialang
Learn.jl
JuliaML bundled in a convenient all-in-one toolkit.
Stars: ✭ 57 (+46.15%)
Mutual labels:  julialang
PlutoStaticHTML.jl
Convert Pluto notebooks to HTML in automated workflows
Stars: ✭ 69 (+76.92%)
Mutual labels:  julialang

FastClosures

Build Status

A workaround for JuliaLang/julia#15276, for julia-1.x, somewhat in the spirit of FastAnonymous.jl. Provides the @closure macro, which wraps a closure in a let block to make reading variable bindings private to the closure. In certain cases, this make using the closure - and the code surrouding it - much faster. Note that it's not clear that the let block trick implemented in this package helps at all in julia-0.5. However, julia-0.5 compatibility is provided for backward compatibility convenience.

Interface

    @closure closure_expression

Wrap the closure definition closure_expression in a let block to encourage the julia compiler to generate improved type information. For example:

callfunc(f) = f()

function foo(n)
   for i=1:n
       if i >= n
           # Unlikely event - should be fast.  However, capture of `i` inside
           # the closure confuses the julia-0.6 compiler and causes it to box
           # the variable `i`, leading to a 100x performance hit if you remove
           # the `@closure`.
           callfunc(@closure ()->println("Hello \$i"))
       end
   end
end

Here's a further example of where this helps:

using FastClosures

# code_warntype problem
function f1()
    if true
    end
    r = 1
    cb = ()->r
    identity(cb)
end

# code_warntype clean
function f2()
    if true
    end
    r = 1
    cb = @closure ()->r
    identity(cb)
end

@code_warntype f1()
@code_warntype f2()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].