diff --git a/_pydemo/max/max.go b/_pydemo/max/max.go new file mode 100644 index 00000000..734e89aa --- /dev/null +++ b/_pydemo/max/max.go @@ -0,0 +1,15 @@ +package main + +import ( + "github.com/goplus/llgo/py" + "github.com/goplus/llgo/py/std" +) + +func main() { + x := std.Max(py.Float(3.0), py.Float(9.0), py.Float(23.0), py.Float(100.0)) + std.Print(x) + + // y := py.List(3.0, 9.0, 23.0, 100.0) + // ymax := std.Max(std.Iter(y)) + // std.Print(ymax) +} diff --git a/py/std/builtins.go b/py/std/builtins.go index bfc21d08..76d6191a 100644 --- a/py/std/builtins.go +++ b/py/std/builtins.go @@ -25,6 +25,106 @@ import ( // https://docs.python.org/3/library/functions.html // https://docs.python.org/3/library/constants.html +//go:linkname Abs py.abs +func Abs(x *py.Object) *py.Object + +// getattr(object, name) +// +//go:linkname GetAttr py.getattr +func GetAttr(object, name *py.Object) *py.Object + +// getattr(object, name, default) +// +//go:linkname GetAttrEx py.getattr +func GetAttrEx(object, name, default_ *py.Object) *py.Object + +// max(iterable, *, key=None) +// max(iterable, *, default, key=None) +// max(arg1, arg2, *args, key=None) +// +// If one positional argument is provided, it should be an iterable. The largest +// item in the iterable is returned. If two or more positional arguments are +// provided, the largest of the positional arguments is returned. +// +//go:linkname Max py.max +func Max(__llgo_va_list ...any) *py.Object + +// min(iterable, *, key=None) +// min(iterable, *, default, key=None) +// min(arg1, arg2, *args, key=None) +// +//go:linkname Min py.min +func Min(__llgo_va_list ...any) *py.Object + +// iter(object) +// +//go:linkname Iter py.iter +func Iter(object *py.Object) *py.Object + +// next(iterator) +// +//go:linkname Next py.next +func Next(iterator *py.Object) *py.Object + +// next(iterator, default) +// +// Retrieve the next item from the iterator by calling its __next__() method. +// If default is given, it is returned if the iterator is exhausted, otherwise +// StopIteration is raised. +// +//go:linkname NextEx py.next +func NextEx(iterator, default_ *py.Object) *py.Object + +// awaitable anext(async_iterator) +// +//go:linkname Anext py.anext +func Anext(asyncIterator *py.Object) *py.Object + +// awaitable anext(async_iterator, default) +// +// When awaited, return the next item from the given asynchronous iterator, +// or default if given and the iterator is exhausted. +// +// This is the async variant of the next() builtin, and behaves similarly. +// +// This calls the __anext__() method of async_iterator, returning an awaitable. +// Awaiting this returns the next value of the iterator. If default is given, +// it is returned if the iterator is exhausted, otherwise StopAsyncIteration is +// raised. +// +//go:linkname AnextEx py.anext +func AnextEx(asyncIterator, default_ *py.Object) *py.Object + +// iter(object, sentinel) +// +//go:linkname IterEx py.iter +func IterEx(callable, sentinel *py.Object) *py.Object + +// vars() +// +//go:linkname Vars py.vars +func Vars() *py.Object + +// vars(object) +// +// Return the __dict__ attribute for a module, class, instance, or any other object +// with a __dict__ attribute. +// +// See https://docs.python.org/3/library/functions.html#vars +// +//go:linkname VarsEx py.vars +func VarsEx(object *py.Object) *py.Object + +// dir() +// +//go:linkname Dir py.dir +func Dir() *py.Object + +// dir(object) +// +//go:linkname DirEx py.dir +func DirEx(object *py.Object) *py.Object + // Invoke the built-in help system. (This function is intended for interactive // use.) If no argument is given, the interactive help system starts on the // interpreter console. If the argument is a string, then the string is looked @@ -38,3 +138,10 @@ import ( // //go:linkname Help py.help func Help(object *py.Object) + +// breakpoint(*args, **kws) +// +// See https://docs.python.org/3/library/functions.html#breakpoint +// +//go:linkname Breakpoint py.breakpoint +func Breakpoint(__llgo_va_list ...any)