On Fri, Apr 30, 2010 at 12:49 AM, Florian Bösch <[email protected]> wrote: > On Apr 29, 6:50 pm, Joe Wreschnig <[email protected]> wrote: >> I am also trying to maintain compatibility with existing pyglet code. > > I've tested the runtime differences between backwards compatible and > typeswitching variants: http://paste.pocoo.org/show/207971/ > I basically observe that: > 1) tuple unpacking directly is about 20% slower then single value > assignment > 1) tuple unpacking is a bit faster then tuple indexing (about 20%) > 2) typeswitching on Real is very slow > 3) typeswitching either on a tuple of type values or in an if/elif > construct incurs an overhead between 50% - 150% (depending on what > type is preferred) > > I think that this is a typical example of a backwards compatibility > vs. convenience vs. performance tradeoff decision, these are the > choices: > 1) You can remain backwards compatible and support the new semantics, > but be between 2x - 5x slower in attribute assignment > 2) You can forgo backwards compatibility and be 1.2x slower in > attribute assignment (albeit for 2 values, which is apples vs. > oranges) > 3) You can keep backwards compatibility and not support new semantics, > but be 2x slower (because you force a user to make 2 function calls > for both attributes)
How about we keep scale as it is now but add scale_xy to set both at once? My view is that if someone is setting scale, they are likely setting it once, in which case speed matters not at all, or they are setting it every frame for some period of time likely measured in seconds to minutes, in which case it matters greatly. I also remain unconvinced that typeswitching is a good idea at all, since it's not very Pythonic - who cares if it's a subclass of Python's definition of a number, when what we really care is that you can multiply it by a number and get a number out? -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.
