FAQ
Is there go syntax for printing slices without the brackets?

http://play.golang.org/p/Kw0S7EmC8i

--
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/groups/opt_out.

Search Discussions

  • Brad Fitzpatrick at Aug 7, 2013 at 3:12 pm
    http://play.golang.org/p/sk6JKiN6qQ

    On Wed, Aug 7, 2013 at 8:07 AM, Tony Worm wrote:

    Is there go syntax for printing slices without the brackets?

    http://play.golang.org/p/Kw0S7EmC8i

    --
    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/groups/opt_out.

    --
    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/groups/opt_out.
  • Tony Worm at Aug 7, 2013 at 3:27 pm
    helper function which could be modified to specify formatting

    http://play.golang.org/p/-OBvk2VVv0
    On Wednesday, August 7, 2013 11:07:01 AM UTC-4, Tony Worm wrote:

    Is there go syntax for printing slices without the brackets?

    http://play.golang.org/p/Kw0S7EmC8i
    --
    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/groups/opt_out.
  • David DENG at Aug 7, 2013 at 4:42 pm
    http://play.golang.org/p/qeI6AJ74-E

    David
    On Wednesday, August 7, 2013 11:07:01 PM UTC+8, Tony Worm wrote:

    Is there go syntax for printing slices without the brackets?

    http://play.golang.org/p/Kw0S7EmC8i
    --
    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/groups/opt_out.
  • Tony Worm at Aug 7, 2013 at 5:48 pm
    My aim is to reduce the number of calls to fmt.----

    I think that should reduce the number of i/o events and context switches
    which is the real aim

    printing in a loop doesn't address the original question of a Go syntax,
    which it seems there isn't one. I was hoping something of the varidic
    variety existed
    On Wednesday, August 7, 2013 12:42:12 PM UTC-4, David DENG wrote:

    http://play.golang.org/p/qeI6AJ74-E

    David
    On Wednesday, August 7, 2013 11:07:01 PM UTC+8, Tony Worm wrote:

    Is there go syntax for printing slices without the brackets?

    http://play.golang.org/p/Kw0S7EmC8i
    --
    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/groups/opt_out.
  • Dave Cheney at Aug 7, 2013 at 11:29 pm

    My aim is to reduce the number of calls to fmt.----

    I think that should reduce the number of i/o events and context switches
    which is the real aim
    Those two operations sound unrelated. Do you need to use a buffered writer ?

    --
    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/groups/opt_out.
  • Tony Worm at Aug 7, 2013 at 11:47 pm
    calls to printf and scanf involve asking the operating system to do
    something on your behalf as I recall. I don't see how Go could do it
    otherwise.

    Imagine printing 1MM floats with 1MM printf's...

    I'd guess there is some buffering going on somewhere,
    but I recall it being faster to build large strings in memory
    and then print that out with one call to printf

    Anyhow, I was originally looking for some sweet gopher magic on the syntax
    side of this.

    btw, I heard that Go's syntax is in part based on the Limbo scripting
    language from Inferno

    On Wed, Aug 7, 2013 at 7:29 PM, Dave Cheney wrote:

    My aim is to reduce the number of calls to fmt.----

    I think that should reduce the number of i/o events and context switches
    which is the real aim
    Those two operations sound unrelated. Do you need to use a buffered writer
    ?
    --
    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/groups/opt_out.
  • Jens Alfke at Aug 8, 2013 at 12:50 am

    On Wednesday, August 7, 2013 4:47:15 PM UTC-7, Tony Worm wrote:
    calls to printf and scanf involve asking the operating system to do
    something on your behalf as I recall. I don't see how Go could do it
    otherwise.
    I haven't looked at the implementation of Printf, but there's usually
    buffering in between. It's entirely possible that Printf buffers the entire
    output in memory and then makes one Write call. Or maybe it buffers in 32k
    chunks or something. And at a higher level, the output streams might buffer
    in memory before writing to the OS's streams.

    I'd guess there is some buffering going on somewhere,
    but I recall it being faster to build large strings in memory
    and then print that out with one call to printf
    I think you're over-optimizing. Do it in a way that makes sense to you,
    then if it's too slow you can profile it and find out where the bottlenecks
    are. As David said, formatted IO is pretty CPU-intensive to begin with.

    --Jens

    --
    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/groups/opt_out.
  • Andrey mirtchovski at Aug 8, 2013 at 12:54 am
    anything you do with fmt (and consequently reflection) will be much
    more computationally expensive than reslicing the result to
    [1:len()-1] to remove the square brackets.

    btw, limbo is not a scripting language.

    cheers!

    --
    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/groups/opt_out.
  • Rob Pike at Aug 8, 2013 at 1:15 am
    It's not documented but yes, Printf etc. do a single write system call for
    each call, which means they buffer it all up first. (I have been bothered
    too many times in the past by C's printf intertwingling my output.)

    Perhaps this should be documented, or perhaps it should not, so we can
    flush partial results to avoid blowups.

    -rob

    --
    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/groups/opt_out.
  • David DENG at Aug 8, 2013 at 12:12 am
    Calling to fmt.Printxxxx is always expensive. For most of the time, you
    needn't optimize it.

    David
    On Thursday, August 8, 2013 1:48:47 AM UTC+8, Tony Worm wrote:

    My aim is to reduce the number of calls to fmt.----

    I think that should reduce the number of i/o events and context switches
    which is the real aim

    printing in a loop doesn't address the original question of a Go syntax,
    which it seems there isn't one. I was hoping something of the varidic
    variety existed
    On Wednesday, August 7, 2013 12:42:12 PM UTC-4, David DENG wrote:

    http://play.golang.org/p/qeI6AJ74-E

    David
    On Wednesday, August 7, 2013 11:07:01 PM UTC+8, Tony Worm wrote:

    Is there go syntax for printing slices without the brackets?

    http://play.golang.org/p/Kw0S7EmC8i
    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 7, '13 at 3:07p
activeAug 8, '13 at 1:15a
posts11
users7
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase