Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guicho271828/hypercast
H Y P E R C A S T
https://github.com/guicho271828/hypercast
Last synced: 29 days ago
JSON representation
H Y P E R C A S T
- Host: GitHub
- URL: https://github.com/guicho271828/hypercast
- Owner: guicho271828
- Created: 2016-06-14T10:32:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-25T12:20:14.000Z (over 8 years ago)
- Last Synced: 2024-10-15T14:10:59.672Z (3 months ago)
- Language: Common Lisp
- Size: 35.2 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hypercast - Fast, generic, automatic type casting (conversion) framework
```licp
(cast 5 'bit-vector)
; -> #*1010000000000000000000000000000000000000000000000000000000000000(cast #\c 'bit-vector)
; -> (cast (cast #\c 'fixnum) 'bit-vector)
; -> (cast 99 'bit-vector)
; -> #*1100011000000000000000000000000000000000000000000000000000000000
```Highlights:
+ **Better alternative to cl:coerce**: Define the set of atomic converters. The semantics for the primary exported function, `cast`, is the same as `cl:coerce`.
+ `cast` accepts all target types supported by `coerce` in ANSI
+ **Minimal dispatching overhead**: Implemented with `inline-generic-function`, so it is **as fast as** the case of using compiler-macros (no dynamic dispatch as long as the second argument is a constant) and **as powerful as** CLOS generic functions.
+ **Automatic Conversion**: When no implementation of direct conversion is available, it tries to convert the value to the desired type by finding the optimal conversion sequence using dijkstra search. Conversion sequence is found as a path in the directed graph defined by the set of atomic converters. Edge cost is heuristically encoded in the `cost` generic function.
+ Currently the path finding in the type space is done in runtime, but I plan to move it to the compile time in the near future.This library aims at consolidating and connecting several libraries related to data conversion:
+ bit-smasher
+ JSON-related libs
+ BDDs
+ octetsIn terms of implementing each atomic converter, this library could be viewed as a *parasitic* library in that it may carry codes from various existing libraries, or just call the APIs of those libraries.
## Preliminary Performance Evaluation
Preliminary results only.
+ We measured the runtime of converting a fixnum to various types for 3000000 iterations each using `cl:time`.
+ The target types are a bitvector (bitwise encoding), a character (code-char) and octet-vector (code from ironclad).
+ We compare the runtimes between the inlined GF by `inlined-generic-function` and the standard generic function in ANSI CL.+ Environent: Thinkpad X61, Core2Duo 1.8GHz, running on battery
| target type | standard GF | inlined GF |
|--------------|-------------|------------|
| bitvector | 2.247 (sec) | 1.764 |
| character | 0.436 | 0.004 |
| octet-vector | 1.003 | 0.304 |## Dependencies
This library is at least tested on implementation listed below:+ SBCL 1.3.5 on X86-64 Linux 3.13.0-87-generic (author's environment)
Also, it depends on the following libraries:
+ iterate by ** :
Jonathan Amsterdam's iterator/gatherer/accumulator facility
+ alexandria by ** :
Alexandria is a collection of portable public domain utilities.
+ inlined-generic-function by *Masataro Asai* :
MOP implementation of the fast inlinable generic functions dispatched in compile-time## Author
* Masataro Asai ([email protected])
## Copyright
Copyright (c) 2016 Masataro Asai ([email protected])
# License
Licensed under the LLGPL License.