nimpylib
nimpylib copied to clipboard
Built-in functions porting progress
- [x]
abs() - [x]
all() - [x]
any() - [ ]
ascii() - [x]
bin() - [x]
bool()note: calledtoBoolin pylib - [ ] ~~
breakpoint()~~ Not really possible - [ ]
bytearray() - [ ]
bytes() - [ ]
callable() - [x]
chr() - [ ]
classmethod() - [ ]
compile() - [ ]
complex() - [ ]
delattr() - [ ]
dict() - [ ]
dir() - [x]
divmod() - [x]
enumerate() - [ ] ~~
eval()~~ Can't be implemented - [ ] ~~
exec()~~ Can't be implemented - [x]
filter() - [x]
float()note: it's calledtoFloatin pylib - [ ]
format() - [ ]
frozenset() - [ ]
getattr() - [ ] ~~
globals()~~ Can't be implemented - [ ]
hasattr() - [ ]
hash() - [ ]
help() - [x]
hex() - [x]
id()currently uses unsafeAddr, maybe we can use something else? - [x]
input() - [x]
int()note: it's calledtoIntin pylib - [x]
isinstance() - [x]
issubclass() - [x]
iter() - [ ]
len() - [x]
list() - [ ] ~~
locals()~~ Can't be implemented - [x]
map() - [x]
max() - [ ]
memoryview() - [x]
min() - [ ]
next() - [ ]
object() - [x]
oct() - [x]
open() - [x]
ord() - [ ]
pow() - [x]
print() - [ ]
property() - [x]
range() - [ ]
repr() - [ ]
reversed() - [ ]
round() - [ ]
set() - [ ]
setattr() - [ ]
slice() - [ ]
sorted() - [ ]
staticmethod() - [x]
str() - [x]
sum() - [ ]
super() - [ ]
tuple() - [ ]
type() - [ ]
vars() - [ ]
zip() - [ ]
__import__()
Beware: some of these procedures are not yet pushed to the repo.
Yay! :grinning::+1:
About the unticked python's function or class
First, there are some of these functions that can be easily implemented:
- slice() can be by
system.countup() - ascii() can be implemented by the help of
unicode.Rune's proc (I have made it alreadly) - vars() can be by
system.fieldPairsfor object and tuple
Next, I 'd say that some of these functions are alreadly implememented by nim itself:
- round(x[,n]) in std/math
- proc sorted[T](a: openArray[T]; cmp: proc (x, y: T): int; order = SortOrder.Ascending): seq)[T] {.effectsOf: cmp.} in std/algorithm
- reversed[T](a: openArray[T]): seq[T] in std/algorithm
- zip[S,T](s1:openArray[S];s2:openArray[T]): seq[(S,T]) in std/sequtils
- 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:
- locals() : in Nim it's a static view. And when in the global scope, it's always empty.
- 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