JuliaString / Format.jl

A Julia package to provide C and Python-like formatting support
Other
40 stars 6 forks source link

Feature Request: let `generate_formatter` also support the keyword args from `format` #79

Open schlichtanders opened 8 months ago

schlichtanders commented 8 months ago

I find the format function awesome. It is very intuitive. And sometimes, I even like to put it into a kind of generate_formatter, like myformat(x) = format(x, width=3). This is slow as said in the README. Hence it would be awesome if generate_formatter(width=3, ...) would work to create an efficient version of this.

ScottPJones commented 7 months ago

I'm not sure how this could be accomplished, because format (and fmt) work by looking at the type of x, and the format is based on that. generate_formatter looks up a fixed format string, and either uses a cached FormatSpec, or creates one and caches it.

I'll try to think of a way that it could be optimized - it would need additional information not in FormatSpec to support all of the options such as autoscale, fractionsep, fractionwidth, mixedfraction, mixedfractionsep, parens, stripzeros, suffix, tryden.