Skip to content

AudioFrame deep copy #189

Closed
Closed
@microbit-carlos

Description

@microbit-carlos

I think the last time we discussed this, we covered two options:

a) Copy Constructor: original = AudioFrame(); copy = AudioFrame(original)
b) Method: original = AudioFrame(); copy = original.clone()

Option a) is more Pythonic, while option b) might have been already used in the micro:bit API.

I had an action to look at the existing micro:bit API to see if a) and b) has been used before and which one might be more "microbitish".

  • We currently have two instances of a copy() method with SoundEffect.copy() and Image.copy()
  • We don't have any instance of a copy constructor

Apart from that, we already have keyword arguments in AudioFrame(duration, rate) that we can used as positional arguments in the initialiser, and adding a copy constructor might make the readthedocs signature a bit harder to document (we've had multiple questions about characters like * and / in the function signatures). This one is a minor thing, as we can also explain stuff more in the description, but still worth pointing out.

All in all, I think we should go with the AudioFrame.clone() option, but calling it AudioFrame.copy().

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions