You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package is pure Julia. Setting up this package is like setting up other Julia packages:
28
-
29
-
```julia
30
-
Pkg.add("Formatting")
31
-
```
40
+
This package is pure Julia. It is now registered, so it can be added simply with `Pkg.add("Format")`.
41
+
Note: The default branch is `newmaster` instead of `master`, remember that if you wish to make a PR on this package. (It is forked off of [Formatting.jl](https://github.com/JuliaIO/Formatting.jl), and I try to keep the master branch up to date with that, and cherry pick or port all necessary changes to `Format`).
32
42
33
43
To start using the package, you can simply write
34
44
35
45
```julia
36
-
usingFormatting
46
+
usingFormat
37
47
```
38
48
39
-
This package depends on Julia of version 0.2 or above. It has no other dependencies. The package is MIT-licensed.
49
+
This package depends on Julia of version 0.6 or above, and. The package is MIT-licensed.
40
50
41
51
42
52
## Python-style Types and Functions
@@ -111,9 +121,9 @@ One can use ``printfmt`` and ``printfmtln`` for formatted printing:
111
121
112
122
#### Formatted String
113
123
114
-
One can use ``fmt`` to format a single value into a string, or ``format`` to format one to multiple arguments into a string using an format expression.
124
+
One can use ``pyfmt`` to format a single value into a string, or ``format`` to format one to multiple arguments into a string using an format expression.
115
125
116
-
-**fmt**(fspec, a)
126
+
-**pyfmt**(fspec, a)
117
127
118
128
Format a single value using a format specification given by ``fspec``, where``fspec`` can be either a string or an instance of ``FormatSpec``.
119
129
@@ -146,7 +156,7 @@ stripping trailing zeros, and mixed fractions.
146
156
### Usage and Implementation
147
157
148
158
The idea here is that the package compiles a function only once for each unique
149
-
format string within the `Formatting.*` name space, so repeated use is faster.
159
+
format string within the `Format.*` name space, so repeated use is faster.
150
160
Unrelated parts of a session using the same format string would reuse the same
151
161
function, avoiding redundant compilation. To avoid the proliferation of
152
162
functions, we limit the usage to only 1 argument. Practical consideration
@@ -155,10 +165,10 @@ seems manageable.
155
165
156
166
Usage
157
167
```julia
158
-
using Formatting
168
+
using Format
159
169
160
170
fmt = "%10.3f"
161
-
s = sprintf1( fmt, 3.14159 ) # usage 1. Quite performant. Easiest to switch to.
171
+
s = cfmt( fmt, 3.14159 ) # usage 1. Quite performant. Easiest to switch to.
162
172
163
173
fmtrfunc = generate_formatter( fmt ) # usage 2. This bypass repeated lookup of cached function. Most performant.
164
174
s = fmtrfunc( 3.14159 )
@@ -167,7 +177,7 @@ s = format( 3.14159, precision=3 ) # usage 3. Most flexible, with some non-print
167
177
```
168
178
### Speed
169
179
170
-
`sprintf1`: Speed penalty is about 20%for floating point and 30%for integers.
180
+
`cfmt`: Speed penalty is about 20%for floating point and 30%for integers.
171
181
172
182
If the formatter is stored and used instead (see the example using`generate_formatter` above),
173
183
the speed penalty reduces to 10%for floating point and 15%for integers.
0 commit comments