ownership problem?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriel Zachmann

    #1

    ownership problem?

    Is it correct to say that the typical ownership problem, which frequently
    arises in C++, does not occur normally in Python?

    Best regards,
    Gabriel.

    --
    /-----------------------------------------------------------------------\
    | Any intelligent fool can make things bigger, more complex, |
    | or more violent. It takes a touch of genius - and a lot of courage - |
    | to move in the opposite direction. (Einstein) |
    \-----------------------------------------------------------------------/
  • Bruno Desthuilliers

    #2
    Re: ownership problem?

    Gabriel Zachmann a écrit :[color=blue]
    > Is it correct to say that the typical ownership problem, which
    > frequently arises in C++, does not occur normally in Python?[/color]

    What is this "typical ownership problem" ?

    Comment

    • Bruno Desthuilliers

      #3
      Re: ownership problem?

      Gabriel Zachmann a écrit :[color=blue]
      > Is it correct to say that the typical ownership problem, which
      > frequently arises in C++, does not occur normally in Python?[/color]

      What is this "typical ownership problem" ?

      Comment

      • Ben Finney

        #4
        Re: ownership problem?

        Gabriel Zachmann <zach@in.tu-clausthal.de> wrote:[color=blue]
        > Is it correct to say that the typical ownership problem, which
        > frequently arises in C++, does not occur normally in Python?[/color]

        Could you explain what you mean by "the typical ownership problem"?

        --
        \ "Jealousy: The theory that some other fellow has just as little |
        `\ taste." -- Henry L. Mencken |
        _o__) |
        Ben Finney

        Comment

        • Ben Finney

          #5
          Re: ownership problem?

          Gabriel Zachmann <zach@in.tu-clausthal.de> wrote:[color=blue]
          > Is it correct to say that the typical ownership problem, which
          > frequently arises in C++, does not occur normally in Python?[/color]

          Could you explain what you mean by "the typical ownership problem"?

          --
          \ "Jealousy: The theory that some other fellow has just as little |
          `\ taste." -- Henry L. Mencken |
          _o__) |
          Ben Finney

          Comment

          • Jeffrey Schwab

            #6
            Re: ownership problem?

            Gabriel Zachmann wrote:[color=blue]
            > Is it correct to say that the typical ownership problem, which
            > frequently arises in C++, does not occur normally in Python?[/color]

            What "typical ownership problem" do you feel frequently arises in C++?
            If you are referring to the sometimes difficult task of determining
            which object owns a particular resource, why would it occur less in
            Python than in C++?

            Comment

            • Jeffrey Schwab

              #7
              Re: ownership problem?

              Gabriel Zachmann wrote:[color=blue]
              > Is it correct to say that the typical ownership problem, which
              > frequently arises in C++, does not occur normally in Python?[/color]

              What "typical ownership problem" do you feel frequently arises in C++?
              If you are referring to the sometimes difficult task of determining
              which object owns a particular resource, why would it occur less in
              Python than in C++?

              Comment

              • Fredrik Lundh

                #8
                Re: ownership problem?

                Jeffrey Schwab wrote:
                [color=blue][color=green]
                > > Is it correct to say that the typical ownership problem, which
                > > frequently arises in C++, does not occur normally in Python?[/color]
                >
                > What "typical ownership problem" do you feel frequently arises in C++?
                > If you are referring to the sometimes difficult task of determining
                > which object owns a particular resource, why would it occur less in
                > Python than in C++?[/color]

                the problem isn't determining who owns it, the problem is determining
                who's supposed to release it. that's not a very common problem in a
                garbage-collected language...

                </F>



                Comment

                • Fredrik Lundh

                  #9
                  Re: ownership problem?

                  Jeffrey Schwab wrote:
                  [color=blue][color=green]
                  > > Is it correct to say that the typical ownership problem, which
                  > > frequently arises in C++, does not occur normally in Python?[/color]
                  >
                  > What "typical ownership problem" do you feel frequently arises in C++?
                  > If you are referring to the sometimes difficult task of determining
                  > which object owns a particular resource, why would it occur less in
                  > Python than in C++?[/color]

                  the problem isn't determining who owns it, the problem is determining
                  who's supposed to release it. that's not a very common problem in a
                  garbage-collected language...

                  </F>



                  Comment

                  • Jeffrey Schwab

                    #10
                    Re: ownership problem?

                    Fredrik Lundh wrote:[color=blue]
                    > Jeffrey Schwab wrote:
                    >
                    >[color=green][color=darkred]
                    >>>Is it correct to say that the typical ownership problem, which
                    >>>frequently arises in C++, does not occur normally in Python?[/color]
                    >>
                    >>What "typical ownership problem" do you feel frequently arises in C++?
                    >>If you are referring to the sometimes difficult task of determining
                    >>which object owns a particular resource, why would it occur less in
                    >>Python than in C++?[/color]
                    >
                    >
                    > the problem isn't determining who owns it, the problem is determining
                    > who's supposed to release it. that's not a very common problem in a
                    > garbage-collected language...[/color]

                    Yes it is. Memory is only one type of resource. There are still files
                    and sockets to close, pipes to flush, log messages to be printed, GDI
                    contexts to free, locks to release, etc. In C++, these things are
                    generally done by destructors, which are called automatically and
                    deterministical ly. I am not a Python Guru, but in Perl, Java, and other
                    languages that have built-in garbage collectors, these tasks have to be
                    done explicitly. I find that this forces a procedural approach, even in
                    an otherwise object-oriented program.

                    If you want something like automatic garbage collection in C++, I
                    recommend the use of Factories with destructors that release the
                    Factories' products. The zeitgeist in c.l.c++.moderat ed seems to prefer
                    the use of smart (reference-counted) pointers, which also rely on
                    destructors to release resources automatically. Plentry of free,
                    open-source implementations are available.

                    Comment

                    • Jeffrey Schwab

                      #11
                      Re: ownership problem?

                      Fredrik Lundh wrote:[color=blue]
                      > Jeffrey Schwab wrote:
                      >
                      >[color=green][color=darkred]
                      >>>Is it correct to say that the typical ownership problem, which
                      >>>frequently arises in C++, does not occur normally in Python?[/color]
                      >>
                      >>What "typical ownership problem" do you feel frequently arises in C++?
                      >>If you are referring to the sometimes difficult task of determining
                      >>which object owns a particular resource, why would it occur less in
                      >>Python than in C++?[/color]
                      >
                      >
                      > the problem isn't determining who owns it, the problem is determining
                      > who's supposed to release it. that's not a very common problem in a
                      > garbage-collected language...[/color]

                      Yes it is. Memory is only one type of resource. There are still files
                      and sockets to close, pipes to flush, log messages to be printed, GDI
                      contexts to free, locks to release, etc. In C++, these things are
                      generally done by destructors, which are called automatically and
                      deterministical ly. I am not a Python Guru, but in Perl, Java, and other
                      languages that have built-in garbage collectors, these tasks have to be
                      done explicitly. I find that this forces a procedural approach, even in
                      an otherwise object-oriented program.

                      If you want something like automatic garbage collection in C++, I
                      recommend the use of Factories with destructors that release the
                      Factories' products. The zeitgeist in c.l.c++.moderat ed seems to prefer
                      the use of smart (reference-counted) pointers, which also rely on
                      destructors to release resources automatically. Plentry of free,
                      open-source implementations are available.

                      Comment

                      • elbertlev@hotmail.com

                        #12
                        Re: ownership problem?

                        Yes!
                        Python uses auto garbage collection. As soon as the object reference
                        count becomes 0 it is removed from existence. So the problem typical
                        for C/C++: accessing pointers
                        to already deleted objects does not exist in Python.

                        Comment

                        • elbertlev@hotmail.com

                          #13
                          Re: ownership problem?

                          Yes!
                          Python uses auto garbage collection. As soon as the object reference
                          count becomes 0 it is removed from existence. So the problem typical
                          for C/C++: accessing pointers
                          to already deleted objects does not exist in Python.

                          Comment

                          • Fredrik Lundh

                            #14
                            Re: ownership problem?

                            Jeffrey Schwab wrote:
                            [color=blue][color=green]
                            > > the problem isn't determining who owns it, the problem is determining
                            > > who's supposed to release it. that's not a very common problem in a
                            > > garbage-collected language...[/color]
                            >
                            > Yes it is. Memory is only one type of resource.[/color]

                            Python's garbage collector deals with objects, not memory.
                            [color=blue]
                            > I am not a Python Guru[/color]

                            from the sound of it, you haven't written serious programs in any of the
                            languages you mention.

                            </F>



                            Comment

                            • Fredrik Lundh

                              #15
                              Re: ownership problem?

                              Jeffrey Schwab wrote:
                              [color=blue][color=green]
                              > > the problem isn't determining who owns it, the problem is determining
                              > > who's supposed to release it. that's not a very common problem in a
                              > > garbage-collected language...[/color]
                              >
                              > Yes it is. Memory is only one type of resource.[/color]

                              Python's garbage collector deals with objects, not memory.
                              [color=blue]
                              > I am not a Python Guru[/color]

                              from the sound of it, you haven't written serious programs in any of the
                              languages you mention.

                              </F>



                              Comment

                              Working...