benchmark

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M8R-n7vorv@mailinator.com

    #31
    Re: benchmark

    On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
    jlist wrote:
    I think what makes more sense is to compare the code one most
    typically writes. In my case, I always use range() and never use psyco.
    But I guess for most of my work with Python performance hasn't been
    a issue. I haven't got to write any large systems with Python yet, where
    performance starts to matter.
    >
    Hopefully when you do you will improve your programming practices to not
    make poor choices - there are few excuses for not using xrange ;)
    >
    Kris
    And can you shed some light on how that relates with one of the zens
    of python ?

    There should be one-- and preferably only one --obvious way to do it.

    Dhananjay

    Comment

    • cokofreedom@gmail.com

      #32
      Re: benchmark

      On Aug 11, 10:55 am, M8R-n7v...@mailinat or.com wrote:
      On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
      >
      jlist wrote:
      I think what makes more sense is to compare the code one most
      typically writes. In my case, I always use range() and never use psyco.
      But I guess for most of my work with Python performance hasn't been
      a issue. I haven't got to write any large systems with Python yet, where
      performance starts to matter.
      >
      Hopefully when you do you will improve your programming practices to not
      make poor choices - there are few excuses for not using xrange ;)
      >
      Kris
      >
      And can you shed some light on how that relates with one of the zens
      of python ?
      >
      There should be one-- and preferably only one --obvious way to do it.
      >
      Dhananjay
      And that is xrange, but if you need a list range is better :P

      Comment

      • Peter Otten

        #33
        Re: benchmark

        M8R-n7vorv@mailinat or.com wrote:
        On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
        >jlist wrote:
        I think what makes more sense is to compare the code one most
        typically writes. In my case, I always use range() and never use psyco.
        But I guess for most of my work with Python performance hasn't been
        a issue. I haven't got to write any large systems with Python yet,
        where performance starts to matter.
        >>
        >Hopefully when you do you will improve your programming practices to not
        >make poor choices - there are few excuses for not using xrange ;)
        >>
        >Kris
        >
        And can you shed some light on how that relates with one of the zens
        of python ?
        >
        There should be one-- and preferably only one --obvious way to do it.
        For the record, the impact of range() versus xrange() is negligable -- on my
        machine the xrange() variant even runs a tad slower. So it's not clear
        whether Kris actually knows what he's doing.

        For the cases where xrange() is an improvement over range() "Practicali ty
        beats purity" applies. But you should really care more about the spirit
        than the letter of the "zen".

        Peter

        Comment

        • M8R-n7vorv@mailinator.com

          #34
          Re: benchmark

          On Aug 11, 2:09 pm, cokofree...@gma il.com wrote:
          On Aug 11, 10:55 am, M8R-n7v...@mailinat or.com wrote:
          >
          >
          >
          On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
          >
          jlist wrote:
          I think what makes more sense is to compare the code one most
          typically writes. In my case, I always use range() and never use psyco.
          But I guess for most of my work with Python performance hasn't been
          a issue. I haven't got to write any large systems with Python yet, where
          performance starts to matter.
          >
          Hopefully when you do you will improve your programming practices to not
          make poor choices - there are few excuses for not using xrange ;)
          >
          Kris
          >
          And can you shed some light on how that relates with one of the zens
          of python ?
          >
          There should be one-- and preferably only one --obvious way to do it.
          >
          Dhananjay
          >
          And that is xrange, but if you need a list range is better :P
          Interesting to read from PEP-3000 : "Python 2.6 will support forward
          compatibility in the following two ways:

          * It will support a "Py3k warnings mode" which will warn
          dynamically (i.e. at runtime) about features that will stop working in
          Python 3.0, e.g. assuming that range() returns a list."

          Comment

          • Kris Kennaway

            #35
            Re: benchmark

            Peter Otten wrote:
            M8R-n7vorv@mailinat or.com wrote:
            >
            >On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
            >>jlist wrote:
            >>>I think what makes more sense is to compare the code one most
            >>>typically writes. In my case, I always use range() and never use psyco.
            >>>But I guess for most of my work with Python performance hasn't been
            >>>a issue. I haven't got to write any large systems with Python yet,
            >>>where performance starts to matter.
            >>Hopefully when you do you will improve your programming practices to not
            >>make poor choices - there are few excuses for not using xrange ;)
            >>>
            >>Kris
            >And can you shed some light on how that relates with one of the zens
            >of python ?
            >>
            >There should be one-- and preferably only one --obvious way to do it.
            >
            For the record, the impact of range() versus xrange() is negligable -- on my
            machine the xrange() variant even runs a tad slower. So it's not clear
            whether Kris actually knows what he's doing.
            You are only thinking in terms of execution speed. Now think about
            memory use. Using iterators instead of constructing lists is something
            that needs to permeate your thinking about python or you will forever be
            writing code that wastes memory, sometimes to a large extent.

            Kris

            Comment

            • Peter Otten

              #36
              Re: benchmark

              Kris Kennaway wrote:
              Peter Otten wrote:
              >M8R-n7vorv@mailinat or.com wrote:
              >>
              >>On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
              >>>jlist wrote:
              >>>>I think what makes more sense is to compare the code one most
              >>>>typically writes. In my case, I always use range() and never use
              >>>>psyco. But I guess for most of my work with Python performance hasn't
              >>>>been a issue. I haven't got to write any large systems with Python
              >>>>yet, where performance starts to matter.
              >>>Hopefully when you do you will improve your programming practices to
              >>>not make poor choices - there are few excuses for not using xrange ;)
              >>>>
              >>>Kris
              >>And can you shed some light on how that relates with one of the zens
              >>of python ?
              >>>
              >>There should be one-- and preferably only one --obvious way to do it.
              >>
              >For the record, the impact of range() versus xrange() is negligable -- on
              >my machine the xrange() variant even runs a tad slower. So it's not clear
              >whether Kris actually knows what he's doing.
              >
              You are only thinking in terms of execution speed.
              Yes, because my remark was made in the context of the particular benchmark
              supposed to be the topic of this thread.
              Now think about memory use.
              Now you are moving the goal posts, But still, try to increase the chain
              length. I guess you'll find that the impact of range() -- in
              Chain.__init__( ) at least -- on the memory footprint is also negligable
              because the Person objects consume much more memory than the tempory list.
              Using iterators instead of constructing lists is something
              that needs to permeate your thinking about python or you will forever be
              writing code that wastes memory, sometimes to a large extent.
              I like and use an iterator/generator/itertools-based idiom myself, but
              for "small" sequences lists are quite competitive, and the notion of what a
              small list might be is constantly growing.

              In general I think that if you want to promote a particular coding style you
              should pick an example where you can demonstrate actual benefits.

              Peter

              Comment

              • bearophileHUGS@lycos.com

                #37
                Re: benchmark

                Peter Otten:
                In general I think that if you want to promote a particular coding style you
                should pick an example where you can demonstrate actual benefits.
                That good thing is that Python 3 has only xrange (named range), so
                this discussion will be mostly over ;-)

                Bye,
                bearophile

                Comment

                • Kris Kennaway

                  #38
                  Re: benchmark

                  Peter Otten wrote:
                  Kris Kennaway wrote:
                  >
                  >Peter Otten wrote:
                  >>M8R-n7vorv@mailinat or.com wrote:
                  >>>
                  >>>On Aug 10, 10:10 pm, Kris Kennaway <k...@FreeBSD.o rgwrote:
                  >>>>jlist wrote:
                  >>>>>I think what makes more sense is to compare the code one most
                  >>>>>typicall y writes. In my case, I always use range() and never use
                  >>>>>psyco. But I guess for most of my work with Python performance hasn't
                  >>>>>been a issue. I haven't got to write any large systems with Python
                  >>>>>yet, where performance starts to matter.
                  >>>>Hopefully when you do you will improve your programming practices to
                  >>>>not make poor choices - there are few excuses for not using xrange ;)
                  >>>>>
                  >>>>Kris
                  >>>And can you shed some light on how that relates with one of the zens
                  >>>of python ?
                  >>>>
                  >>>There should be one-- and preferably only one --obvious way to do it.
                  >>For the record, the impact of range() versus xrange() is negligable -- on
                  >>my machine the xrange() variant even runs a tad slower. So it's not clear
                  >>whether Kris actually knows what he's doing.
                  >You are only thinking in terms of execution speed.
                  >
                  Yes, because my remark was made in the context of the particular benchmark
                  supposed to be the topic of this thread.
                  No, you may notice that the above text has moved off onto another
                  discussion.

                  Kris

                  Comment

                  Working...