Skip to content
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

Built-in functions porting progress #11

Open
28 of 69 tasks
Yardanico opened this issue Jul 14, 2018 · 3 comments
Open
28 of 69 tasks

Built-in functions porting progress #11

Yardanico opened this issue Jul 14, 2018 · 3 comments

Comments

@Yardanico
Copy link
Owner

Yardanico commented Jul 14, 2018

  • abs()
  • all()
  • any()
  • ascii()
  • bin()
  • bool() note: called toBool in pylib
  • breakpoint() Not really possible
  • bytearray()
  • bytes()
  • callable()
  • chr()
  • classmethod()
  • compile()
  • complex()
  • delattr()
  • dict()
  • dir()
  • divmod()
  • enumerate()
  • eval() Can't be implemented
  • exec() Can't be implemented
  • filter()
  • float() note: it's called toFloat in pylib
  • format()
  • frozenset()
  • getattr()
  • globals() Can't be implemented
  • hasattr()
  • hash()
  • help()
  • hex()
  • id() currently uses unsafeAddr, maybe we can use something else?
  • input()
  • int() note: it's called toInt in pylib
  • isinstance()
  • issubclass()
  • iter()
  • len()
  • list()
  • locals() Can't be implemented
  • map()
  • max()
  • memoryview()
  • min()
  • next()
  • object()
  • oct()
  • open()
  • ord()
  • pow()
  • print()
  • property()
  • range()
  • repr()
  • reversed()
  • round()
  • set()
  • setattr()
  • slice()
  • sorted()
  • staticmethod()
  • str()
  • sum()
  • super()
  • tuple()
  • type()
  • vars()
  • zip()
  • __import__()
@Yardanico Yardanico self-assigned this Jul 14, 2018
@Yardanico
Copy link
Owner Author

Beware: some of these procedures are not yet pushed to the repo.

@Yardanico Yardanico changed the title Python built-in functions porting progress Built-in functions porting progress Jul 14, 2018
@juancarlospaco
Copy link
Collaborator

Yay! 😀👍

@litlighilit
Copy link
Contributor

About the unticked python's function or class
First, there are some of these functions that can be easily implemented:

  1. slice() can be by system.countup()
  2. ascii() can be implemented by the help of unicode.Rune's proc (I have made it alreadly)
  3. vars() can be by system.fieldPairs for object and tuple

Next, I 'd say that some of these functions are alreadly implememented by nim itself:

  1. round(x[,n]) in std/math
  2. proc sorted[T](a: openArray[T]; cmp: proc (x, y: T): int;
    order = SortOrder.Ascending): seq)[T] {.effectsOf: cmp.}
    in std/algorithm
  3. reversed[T](a: openArray[T]): seq[T] in std/algorithm
  4. zip[S,T](s1:openArray[S];s2:openArray[T]): seq[(S,T]) in std/sequtils
  5. len() for set, array, seq and so on

Then, there are still some of them having behaviors that are similar but not the same a bit:

  1. locals() : in Nim it's a static view. And when in the global scope, it's always empty.
  2. type() : in Nim it's a alias of typeof(), and it can only be used to get something's type , not to create a new type (class)

Finally here is a suggestion:
filter[T](s: openArray[T]; pred: proc (x: T): bool {.closure.}): seq[T] is already in std/algorithm

litlighilit added a commit to litlighilit/nimpylib that referenced this issue Dec 11, 2022
I'd made a comment in Yardanico/nimpylib#11
But then I found that this types.nim exports a `ascii`
However in Python ascii function doesn't the same as str, see https://docs.python.org/3/library/functions.html#ascii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants