Re: [pygame] Why does Rect and Surface have copy method when copy exist in std-lib?

2017-06-03 Thread Daniel Foerster
Allow me to point out that there's such a thing as dict.copy(). It's
pointless to import a module to call a method that you know is made
publicly available already, and just as pointless to make people import.

On Jun 3, 2017 16:23, "Victor Blomqvist"  wrote:

> It seems like such a small performance difference shouldnt affect the
> decision if a custom copy method is good or not?
>
> /Victor
>
> On Thu, Jun 1, 2017 at 9:24 PM, Jason Marshall  > wrote:
>
>> In the C code, rect.copy and surface.copy are equivalent to
>> rect.__copy__ and surface.__copy__. You may use copy.copy(rect) and
>> copy.copy(surface) in your code, but copy.copy will simply call
>> rect.__copy__ or surface.__copy__. By using rect.copy and surface.copy
>> rather than the standard library's copy.copy, your code will run
>> ≈0.0001% faster.
>>
>> For aesthetic reasons, you would use rect.copy and surface.copy rather
>> than rect.__copy__ and surface.__copy__ in your code.
>>
>> Jason
>>
>> On Mon, May 29, 2017 at 3:38 PM, Victor Blomqvist  wrote:
>> > Hello,
>> >
>> > Something I have been thinking about:
>> > Rect and Surface classes have their own copy methods. Why do they have
>> that
>> > when there is a module called copy in the standard lib that can handle
>> copy
>> > (with help)? The rect copy method was added in pygame 1.9 so it is
>> fairly
>> > recent.
>> >
>> > http://pygame.org/docs/ref/rect.html#pygame.Rect.copy
>> > https://docs.python.org/2/library/copy.html
>> >
>> > Thanks for any insights!
>> > /Victor
>>
>
>


Re: [pygame] Why does Rect and Surface have copy method when copy exist in std-lib?

2017-06-03 Thread Victor Blomqvist
It seems like such a small performance difference shouldnt affect the
decision if a custom copy method is good or not?

/Victor

On Thu, Jun 1, 2017 at 9:24 PM, Jason Marshall 
wrote:

> In the C code, rect.copy and surface.copy are equivalent to
> rect.__copy__ and surface.__copy__. You may use copy.copy(rect) and
> copy.copy(surface) in your code, but copy.copy will simply call
> rect.__copy__ or surface.__copy__. By using rect.copy and surface.copy
> rather than the standard library's copy.copy, your code will run
> ≈0.0001% faster.
>
> For aesthetic reasons, you would use rect.copy and surface.copy rather
> than rect.__copy__ and surface.__copy__ in your code.
>
> Jason
>
> On Mon, May 29, 2017 at 3:38 PM, Victor Blomqvist  wrote:
> > Hello,
> >
> > Something I have been thinking about:
> > Rect and Surface classes have their own copy methods. Why do they have
> that
> > when there is a module called copy in the standard lib that can handle
> copy
> > (with help)? The rect copy method was added in pygame 1.9 so it is fairly
> > recent.
> >
> > http://pygame.org/docs/ref/rect.html#pygame.Rect.copy
> > https://docs.python.org/2/library/copy.html
> >
> > Thanks for any insights!
> > /Victor
>