Skip to content

[mypyc] Implement builtins.len primitive for list #9271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add PyObject
  • Loading branch information
TH3CHARLie committed Aug 6, 2020
commit 25addc92ee5ddc18a17bc96a2ac9a54585a43b5d
15 changes: 10 additions & 5 deletions mypyc/primitives/struct_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Struct registries for C backend"""

from typing import List, Dict
from typing import List, Dict, Tuple
from mypyc.ir.rtypes import RType, StructInfo, RStruct, c_pyssize_t_rprimitive, pointer_rprimitive

struct_infos = {} # type: Dict[str, StructInfo]
Expand All @@ -9,7 +9,7 @@

def c_struct(name: str,
names: List[str],
types: List[RType]) -> StructInfo:
types: List[RType]) -> Tuple[StructInfo, RType]:
"""Define a known C struct for generating IR to manipulate it

name: The name of the C struct
Expand All @@ -21,10 +21,15 @@ def c_struct(name: str,
struct_infos[name] = info
typ = RStruct(info)
struct_types[name] = typ
return info
return info, typ


py_object_info, PyObject = c_struct(
name='PyObject',
names=['ob_refcnt', 'ob_type'],
types=[c_pyssize_t_rprimitive, pointer_rprimitive])

c_struct(
name='PyVarObject',
names=['ob_refcnt', 'ob_type', 'ob_size'],
types=[c_pyssize_t_rprimitive, pointer_rprimitive, c_pyssize_t_rprimitive])
names=['ob_base', 'ob_size'],
types=[PyObject, c_pyssize_t_rprimitive])
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy