Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/collegeville/typestability.jl
Automates checking type stability of Julia functions
https://github.com/collegeville/typestability.jl
Last synced: 30 days ago
JSON representation
Automates checking type stability of Julia functions
- Host: GitHub
- URL: https://github.com/collegeville/typestability.jl
- Owner: Collegeville
- License: mit
- Created: 2018-08-07T20:37:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-05T21:49:38.000Z (almost 4 years ago)
- Last Synced: 2024-12-09T08:51:16.350Z (about 1 month ago)
- Language: Julia
- Size: 447 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TypeStability.jl
[![Build Status](https://travis-ci.org/Collegeville/TypeStability.jl.svg?branch=master)](https://travis-ci.org/Collegeville/TypeStability.jl) [![Stable Docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://Collegeville.github.io/TypeStability.jl/stable/) [![Latest Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://Collegeville.github.io/TypeStability.jl/latest/) [![Version](https://img.shields.io/github/release/Collegeville/TypeStability.jl.svg)](https://github.com/Collegeville/TypeStability.jl/releases)
This package provides functions to automate checking functions for type stability. The checks are only run when enabled, which allows the function signatures that need to perform well to be located with the actual code without hurting runtime performance.
TypeStability.jl is tested on Julia versions 0.6 through 1.1.
### License
TypeStability.jl is licensed under the MIT "Expat" license. See [LICENSE.md](LICENSE.md) for more information.
### Setup
Run `Pkg.add(TypeStability)` to install the latest stable version of TypeStability. Then TypeStability can be `using`ed or `import`ed.
### Example
Documentation is located at [https://collegeville.github.io/TypeStability.jl/stable/](https://collegeville.github.io/TypeStability.jl/stable/) or, for the latest version, [https://collegeville.github.io/TypeStability.jl/latest/](https://collegeville.github.io/TypeStability.jl/latest/)
The function `enable_inline_stability_checks(::Bool)` enables running the stability checks, while the macro `@stablefunction(signatures, function)` handles running the checks.
```julia
julia> using TypeStabilityjulia> enable_inline_stability_checks(true)
truejulia> @stable_function [(Float64,)] function f(x)
if x > 0
x
else
Int(0)
end
end
f(Float64) is not stable
return is of type Union{Float64, Int64}julia> f
f (generic function with 1 method)julia> @stable_function [(Float64,)] function g(x)
if x > 0
x
else
0.0
end
endjulia> g
g (generic function with 1 method)
```### Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on contrinbuting to TypeStability.jl.