Home / Function/ __decode__() — anthropic-sdk-python Function Reference

__decode__() — anthropic-sdk-python Function Reference

Architecture documentation for the __decode__() function in jsonl.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  568b5fd3_ee73_7114_f5e0_13601cc2daf6["__decode__()"]
  07143852_a227_9b67_59fe_b20262712b6f["AsyncJSONLDecoder"]
  568b5fd3_ee73_7114_f5e0_13601cc2daf6 -->|defined in| 07143852_a227_9b67_59fe_b20262712b6f
  style 568b5fd3_ee73_7114_f5e0_13601cc2daf6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_decoders/jsonl.py lines 99–116

    async def __decode__(self) -> AsyncIterator[_T]:
        buf = b""
        async for chunk in self._raw_iterator:
            for line in chunk.splitlines(keepends=True):
                buf += line
                if buf.endswith((b"\r", b"\n", b"\r\n")):
                    yield construct_type_unchecked(
                        value=json.loads(buf),
                        type_=self._line_type,
                    )
                    buf = b""

        # flush
        if buf:
            yield construct_type_unchecked(
                value=json.loads(buf),
                type_=self._line_type,
            )

Subdomains

Frequently Asked Questions

What does __decode__() do?
__decode__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_decoders/jsonl.py.
Where is __decode__() defined?
__decode__() is defined in src/anthropic/_decoders/jsonl.py at line 99.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free