Python & Music: Performance question
Steven Taschuk
staschuk at telusplanet.net
Sun Apr 6 16:02:17 EDT 2003
Quoth David Asorey Álvarez:
[...]
> I want define a class, Note, which represents a note. It has two
> attributes, pitch and duration (quarter note, half note, etc). There
> will be a lot of instances of this object, maybe hundreds of notes,
> and the program needs access to all of this objects and read its
> attributes.
> Which implementation will be more efficient?
[...]
I don't know about speed (you should profile when you find it
matters), but for memory efficiency, this sounds like a job for
the Flyweight design pattern.
--
Steven Taschuk staschuk at telusplanet.net
"I'm always serious, never more so than when I'm being flippant."
-- _Look to Windward_, Iain M. Banks
More information about the Python-list
mailing list