Re: CWD + relative path + import name == resultant relative path?

2021-10-30 Thread Dieter Maurer
Dan Stromberg wrote at 2021-10-29 16:38 -0700:
>Is there a predefined function somewhere that can accept the 3 things on
>the LHS in the subject line, and give back a resultant relative path -
>relative to the unchanged CWD?
>
>To illustrate, imagine:
>1) You're sitting in /home/foo/coolprog
>2) You look up the AST for /home/foo/coolprog/a/b/c.py
>3) /home/foo/coolprog/a/b/c.py has a relative import of ..blah

Look at the functions provided by `os.path`.

Maybe, you do not need relative path: look at `importlib`
(which also supports import via absolute paths).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python script seems to stop running when handling very large dataset

2021-10-30 Thread Dieter Maurer
Shaozhong SHI wrote at 2021-10-29 23:42 +0100:
>Python script works well, but seems to stop running at a certain point when
>handling very large dataset.
>
>Can anyone shed light on this?

Some algorithms have non linear runtime.


For example, it is quite easy to write code with
quadratic runtime in Python:
  s = ""
  for x in ...: s += f(x)
You will see the problem only for large data sets.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python script seems to stop running when handling very large dataset

2021-10-30 Thread Shaozhong SHI
On Saturday, 30 October 2021, Dieter Maurer  wrote:

> Shaozhong SHI wrote at 2021-10-29 23:42 +0100:
> >Python script works well, but seems to stop running at a certain point
> when
> >handling very large dataset.
> >
> >Can anyone shed light on this?
>
> Some algorithms have non linear runtime.
>
>
> For example, it is quite easy to write code with
> quadratic runtime in Python:
>   s = ""
>   for x in ...: s += f(x)
> You will see the problem only for large data sets.
>

Has anyone compared this with iterrow?  which looping option is faster?
Regards, David
-- 
https://mail.python.org/mailman/listinfo/python-list