FAQ
My colleague just pointed out that the fmt.Fprint family of functions
buffer the complete output of the formatting operation:

https://github.com/golang/go/blob/master/src/fmt/print.go#L220

When writing to a stream, this seems to introduce unnecessary copying. For
the kind of small stuff that one typically writes with fmt.Fprint it
probably doesn't matter much, but if one ever writes something large, it
might.

Does anyone else think this would be worth doing a PR to optimize?

Cheers,
Ox

-----------------------------------------------------------------------------------------

"I love people who harness themselves, an ox to a heavy cart,
who pull like water buffalo, with massive patience,
who strain in the mud and the muck to move things forward,
who do what has to be done, again and again."

- Marge Piercy

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Viktor Kojouharov at Feb 21, 2015 at 10:01 am
    You should read the first and only open PR in the repo before deciding to do any kind of pull requests.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamás Gulácsi at Feb 21, 2015 at 10:40 am
    For all those print-a-byte calls it should be buffered anyway, and those buffers are reused.

    It is nothing more than gathering all that has to be written into a buffer, than write that buffer out at once.

    If you need more performance, you can call your Writes directly.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ian Lance Taylor at Feb 21, 2015 at 4:37 pm

    On Feb 21, 2015 4:36 AM, "Ox Cart" wrote:
    My colleague just pointed out that the fmt.Fprint family of functions
    buffer the complete output of the formatting operation:
    https://github.com/golang/go/blob/master/src/fmt/print.go#L220

    When writing to a stream, this seems to introduce unnecessary copying.
    For the kind of small stuff that one typically writes with fmt.Fprint it
    probably doesn't matter much, but if one ever writes something large, it
    might.
    Does anyone else think this would be worth doing a PR to optimize?
    A single write prevents interleaving of multiple prints from different
    goroutines. It's a feature, not a bug.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ox Cart at Feb 21, 2015 at 4:39 pm
    Ha, of course! Makes perfect sense. Methinks it's time to get some sleep.

    Thanks.

    Cheers,
    Ox

    -----------------------------------------------------------------------------------------

    "I love people who harness themselves, an ox to a heavy cart,
    who pull like water buffalo, with massive patience,
    who strain in the mud and the muck to move things forward,
    who do what has to be done, again and again."

    - Marge Piercy

    On Sat, Feb 21, 2015 at 10:37 AM, Ian Lance Taylor wrote:

    On Feb 21, 2015 4:36 AM, "Ox Cart" wrote:

    My colleague just pointed out that the fmt.Fprint family of functions
    buffer the complete output of the formatting operation:
    https://github.com/golang/go/blob/master/src/fmt/print.go#L220

    When writing to a stream, this seems to introduce unnecessary copying.
    For the kind of small stuff that one typically writes with fmt.Fprint it
    probably doesn't matter much, but if one ever writes something large, it
    might.
    Does anyone else think this would be worth doing a PR to optimize?
    A single write prevents interleaving of multiple prints from different
    goroutines. It's a feature, not a bug.

    Ian
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 21, '15 at 9:36a
activeFeb 21, '15 at 4:39p
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase