Permalink
Browse files

Add @dynamicCallable to PythonObject.

`PythonObject` now have the `@dynamicCallable` attribute.
They define both the positional/keyword argument variants of the
`dynamicallyCall` method.

The previous `call` and `callMember` methods have been removed.

To call a `PythonObject` with variadic arguments, one can use the dynamic call
sugar: `a(1, 2, 3)`.

To call with an array of arguments, one can use a direct call:
```
let arguments: [Int] = [1, 2, 3]
a.dynamicallyCall(with: arguments)
```

Note: It is not possible to call a `PythonObject` with a non-literal dictionary of arguments.
Todo: Reconsider how to expose throwing calls. `ThrowingPythonObject` does not have the
`@dynamicCallable` attribute because `x.throwing(0, 1, 2)` is confusing.

PiperOrigin-RevId: 197981249
  • Loading branch information...
dan-zheng committed May 25, 2018
1 parent b47ad27 commit 0620447744464af4eb037fc2ca35ceebd5312147
Showing with 111 additions and 154 deletions.
  1. +100 −139 stdlib/public/Python/Python.swift
  2. +11 −15 test/Python/python_runtime.swift
Oops, something went wrong.

0 comments on commit 0620447

Please sign in to comment.