[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Why does Rect and Surface have copy method when copy exist in std-lib?
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Why does Rect and Surface have copy method when copy exist in std-lib?
- From: Jason Marshall <jasonmarshall256@xxxxxxxxx>
- Date: Thu, 1 Jun 2017 14:24:22 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Thu, 01 Jun 2017 15:24:46 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=2Gv1hG9ooM+Mzj8bMa5ZiOSDZ2hSXjGi2Xi3rA+AqF4=; b=UU7JRowvFlwx1HRffKJZgy2Lrcgn+k6eZaSlAZMmy7rl5aC0qx/1e5F3VvGM6T62b5 5wBZjHPNfkX6D07t1WMewB70phAqfJEg/ki0eiXyJwsTprE7kNPMmx+N6mqS9Omzat/W DzZNJNl/fSzciGIkljQ65TsGOi4zWGTGAcOba9IsoYiUmcOAcuh0HWOyJMUnQMCzMOuW YjyX71SY7xS/mgrzf+SgCLl/espR60ykevb6DmNy/VMJf7b6HD2V3hKehG/nCGQLiuzz VcuWEfAYnlmI44LN6H337jO3kW9n8khyGknL6UXfVXGM2NP82QD1q06qt8rI84vPS9bn +kuQ==
- In-reply-to: <CAL870DX=d7F_Y4tfR96if2gxosiOcWgOgbPv4ed6aaizpDxTPA@mail.gmail.com>
- References: <CAL870DX=d7F_Y4tfR96if2gxosiOcWgOgbPv4ed6aaizpDxTPA@mail.gmail.com>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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 <vb@xxxxxxxx> 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