py/std done; demo: max

This commit is contained in:
xushiwei
2024-05-18 23:14:56 +08:00
parent 7228709616
commit 1acfb53c4c
2 changed files with 122 additions and 0 deletions

View File

@@ -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)