Skip to content

Implement bytes(object) #1763

@kevinjwalters

Description

@kevinjwalters

MicroPython doesn't implement bytes(object) at the moment, the method syntax is the only way to execute it, i.e.object.__bytes__(). This can be see in CircuitPython too including 4.0.0 beta 5 (also shown in https://forums.adafruit.com/viewtopic.php?f=60&t=150071), example below from a REPL on CPX:

>>> bytes(obj1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'onetwo' object is not iterable

micropython#3158 notes the absence of this feature and there's a discussion in the comments on the balancing act of memory use by the interpreter.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions