Re: Which architectures to support in a CI like Travis?
I would depend on the project. In the crytoanalysis tool that I developing, "cryptonita", I just manipule bytes. Nothing that could depend on the distro so my CI picks one OS and run the tests there. Project: https://github.com/cryptonitas/cryptonita CI: https://github.com/cryptonitas/cryptonita/blob/master/.github/workflows/test.yml On the other extreme I have "byexample", a tool that takes the examples in your docs and run them as automated tests. It supports different languages (Python, Ruby, Java, ...) and it works using the interpreter of each languages. An there is the challenge for its CI. Because byexample highly depends on the version of the interpreter, the CI config tries a lot of different scenarios Project: https://byexamples.github.io/ CI: https://github.com/byexamples/byexample/blob/master/.github/workflows/test.yml I don't tests different distros but I should for some cases that I suspect that it could be differences in how some interpreters behave. An about OS, I'm planning to add MacOS to the CI because I know that some users had problems in the past in that platform because how byexample interacts with the terminal. So two projects, both in Python, but with two totally different dependencies on the environment where they run, so their CI are different. The two examples are using Gitlab actions but the same applies to TravisCI. Thanks, Martin. On Sun, Sep 18, 2022 at 09:46:45AM +, c.bu...@posteo.jp wrote: Hello, I am using TravisCI for my project on GitHub. The project is packaged for Debian, Ubuntu, Arch and several other distros. All this distros support multiple architectures and they have their own test machines to take care that all packages working on all archs. On my side (upstream) I wonder which arch I should "support" in my TravisCI configuration. I wan't to speed up travis and I want to save energy and carbon. I suspect that my Python code should run on much every platform that offers a Python interpreter. Of course there are edge cases. But they would be captured by the distros own test environments. So is there a good and objective reason to support multiple (and maybe) exotic platforms in a CI pipeline on upstream? Kind Christian -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to replace an instance method?
Just subclass and override whatever method you wish to modify “Private” is conceptual. Mostly it means when the next version of a module comes out, code that you wrote that accesses *._ parts of the module might break. ___ import pandas class MyClass(pandas.ExcelFile.OpenpyxlReader): def _convert_cell(self, cell, convert_float: bool) -> 'Scalar': """override""" # do whatever you want, or call the base class version return super()._convert_cell(cell, convert_float) — Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu On Sep 17, 2022, 5:29 PM -0400, Ralf M. , wrote: *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Am 17.09.2022 um 00:35 schrieb Dan Stromberg: On Fri, Sep 16, 2022 at 2:06 PM Ralf M. mailto:ral...@t-online.de>> wrote: I would like to replace a method of an instance, but don't know how to do it properly. You appear to have a good answer, but... are you sure this is a good idea? It's definitely a dirty hack. It'll probably be confusing to future maintainers of this code, and I doubt static analyzers will like it either. I agree that I will have to add sufficient comments for the future maintainer, should there ever be one (and even for me to still understand it next year). I don't use static analyzers. I'm not the biggest fan of inheritance you'll ever meet, but maybe this is a good place for it? Using a derived version of the class in question to overwrite the method was my first idea, however I don't instantiate the class in question myself, it is instantiated during the initialisation of another class, so I would at least have to derive a modified version of that as well. And that code is rather complex, with metaclasses and custom decorators, and I feel uncomfortable messing with that, while the method I intend to change is quite simple and straightforward. In case anybody is interested what I'm trying to achieve: It's simple in pandas to read an excel file into a dataframe, but only the cell value is read. Sometimes I need more / other information, e.g. some formatting or the hyperlink in a cell. Reopening the file with openpyxl and getting the info is possible, but cumbersome. Looking into the pandas code for reading excel files (which uses openpyxl internally) I noticed a method (of an internal pandas class) that extracts the value from an openpyxl cell. This method is rather simple and seems the ideal spot to change to get what I want. My idea is to instantiate pandas.ExcelFile (official pandas API), get the reader instance (an attribute of the ExcelFile object) and modify the method of the reader instance. The fact that the method I change and the ExcelFile attribute containing the reader are both private (start with _) doesn't make it any better, but I'm desperate enough to be willing to adapt my code to every major pandas release, if necessary. Ralf M. -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mYWFkAugwhU4HgCv9nRg1vSJhyJCA8RApcnyGTRNGQYTTmvVigqANAagTbBwo96YFdHmzfCYU8gN3KpVmcrmOg$ -- https://mail.python.org/mailman/listinfo/python-list
Re: Which architectures to support in a CI like Travis?
On 9/18/22 03:46, c.bu...@posteo.jp wrote: Hello, I am using TravisCI for my project on GitHub. The project is packaged for Debian, Ubuntu, Arch and several other distros. All this distros support multiple architectures and they have their own test machines to take care that all packages working on all archs. On my side (upstream) I wonder which arch I should "support" in my TravisCI configuration. I wan't to speed up travis and I want to save energy and carbon. I suspect that my Python code should run on much every platform that offers a Python interpreter. Of course there are edge cases. But they would be captured by the distros own test environments. So is there a good and objective reason to support multiple (and maybe) exotic platforms in a CI pipeline on upstream? Kind Christian Kind of unrelated to the actual question, but if you start doing anything serious under Travis you'll run out of free minutes rather quickly. My project had to just give up on it after they changed their licensing models -- https://mail.python.org/mailman/listinfo/python-list
Python is not working on my desktop
Sent from [1]Mail for Windows References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 -- https://mail.python.org/mailman/listinfo/python-list
Caching (memoization) in (Gauche / Lisp / Scheme) and Python
so... for a few days i've been revising this Code (in Gauche / Lisp / Scheme) to make it run faster.. and last night i could improve it enough to give me the result i wantedin 72 minutes or so (on my slow PC at home). ( Maybe... within a few months, i'll write the same program in Python to see if it runs 10 or 20 times faster. ) this was the first time i've used Caching (memoization). - instead of calculating (at run-time)Factorial(x) and Combination(x,y) millions of times, i made 2 tables in advance...A simple Table-lookup (Vector-ref in Scheme) seems 100 -- 1000 times faster. One thought i had was... Maybe Python's Factorial(x) and Combination(x,y)(in Numpy ?) are already so fast that... i don't have to do the Caching (memoization) ??? -- https://mail.python.org/mailman/listinfo/python-list
Regarding python 3.10 installation
Hello I’ve been trying to install updated python version i.e. python 10.7. Its showing installed but whenever I open python it comes up with the older version i.e. 10.9 . Please fix this issue is possible -- https://mail.python.org/mailman/listinfo/python-list
Count-Trailing-Zeros(x) --- Can I use Log(x) to see if X is equal to ( Integer * 10 ^ k) ???
Count how many zeros are at the end of your int: defend_zeros(num): s = str(num) return len(s) - len(s.rstrip("0")) print(end_zeros(10)) # == 1 print(end_zeros(101)) # == 0 print(end_zeros(245)) # == 0 print(end_zeros(100100))# == 2 Writing a loop (using % and // ) feels like [reinventing the wheel] and seems intrinsically wrong. i like this code (above) because it's not reinventing the wheel --- the Python implementor has already done the loop (using % and // ), so i'm just using that efficient tool (routine). -- https://mail.python.org/mailman/listinfo/python-list
Re: Which architectures to support in a CI like Travis?
Dear Mats, thanks for the reply. Am 19.09.2022 16:10 schrieb Mats Wichmann: Kind of unrelated to the actual question, but if you start doing anything serious under Travis you'll run out of free minutes rather quickly. My project had to just give up on it after they changed their licensing models I'm new to Travis and didn't noticed that piece of information. ;) Now I am more scared that Travis asked me for my credit card data no matter that I choose a "free" plan. I'm a bit shocked and still don't understand the "credit" infos on my Travis account. There are "Credits" ("used 4470 of 1 credits") and "OSS only credits" ("0 of your 0 monthly credits"). OSS == "open source software" ? I'm confused and thought that Travis is free for public github repos. Any suggestions. Kind Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: memoization (original Subject lost because mailer lost the whole thread)
"Hen Hanna" asked: > so... for a few days i've been revising this Code (in Gauche / Lisp / > Scheme) to make it run faster.. and last night i could improve it enough > to give me the result i wantedin 72 minutes or so (on my slow PC at > home). > ( Maybe... within a few months, i'll write the same program in Python > to see if it runs 10 or 20 times faster. ) > this was the first time i've used Caching (memoization). - instead of > calculating (at run-time)Factorial(x) and Combination(x,y) millions > of times, i made 2 tables in advance...A simple Table-lookup > (Vector-ref in Scheme) seems 100 -- 1000 times faster. > One thought i had was... Maybe Python's Factorial(x) and Combination(x,y) > (in Numpy ?) are already so fast that... i don't have to do the Caching > (memoization) ??? Memoization will generally be very fast -- since it is essentially a table-lookup. If it uses a hash-table (which is common for dictionaries), it would be close to a constant-time access for any entry; otherwise, if it uses some tree structure, it might be logarithmic in the number of entries in the tree. But that fast access comes at a price of storage -- linear with respect to the number of items stored (versus no memory cost incurred when not memoizing). What effect this has when you call these functions "millions of times" depends very much one how many of those calls are on the same values.If all of the calls have different arguments, memoization would not find it in the table yet, and would have to recompute as normal -- and you would end up with no time savings, but a considerable memory allocation for all of those newly-cached values that you never retrieve. The big wins come from asking the same questions repeatedly. Now, as far as Python's functionality, I would not expect it to do any memoization for you. It certainly could not predict what arguments would provide, but it still could still have a reasonable implementation without memoization. Your Factorial(x) and Combination(x,y) would both require a time linear with respect to the value of x, with no memory cost incurred. But if you were to spend most of your application asking the same questions, I would not expect these functions to do any caching or memoization, since I would expect very few applications would have enough calls to these functions to make it worthwhile.So calling these functions, you can expect a linear time for each function call, and if you expect to frequently repeat arguments, then you should add your own memoization for an amortized linear time. And fortunately, Python makes memoization very easy, by using a dictionary as a default value. I've done that often for classroom purposes for cases where it makes a big difference (recursive Fibonacci accelerates from exponential time to linear time). And the process is straightforward enough that you could even define a decorator that could be applied to any function you choose. I don't have an example handy just because I never took the time to write one. Roger Christman Pennsylvania State University -- https://mail.python.org/mailman/listinfo/python-list
Re: How to replace an instance method?
On 9/18/22, Stefan Ram wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated): >>types.MethodType( function, instance ) >>functools.partial( function, instance ) >>new_method.__get__( instance ) > > I wonder which of these three possibilities expresses > the idea of creating a new method from a function and > an instance most clearly. Using types.MethodType(function, instance) is the most clear and correct of the three. Using the function's descriptor __get__() method is equivalent in terms of the result. That said, the descriptor protocol is an intermediate-level concept, so manually calling __get__() isn't friendly to novices or casual users of the language. Using a functools.partial isn't the expected method type, with __func__ and __self__ attributes, and, unlike a method, it doesn't expose the wrapped function's __code__, __name__, __module__, __doc__, __annotations__, __defaults__, __kwdefaults__, __closure__, __globals__, or __builtins__. If dynamic inspection matters, using a functools.partial won't work directly with dis.dis(), inspect.getfile(), inspect.getsource(), inspect.getdoc(), inspect.get_annotations(), inspect.getcallargs(), or inspect.getclosurevars(). -- https://mail.python.org/mailman/listinfo/python-list
Re: How to replace an instance method?
On 2022-09-18 at 09:11:28 +, Stefan Ram wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated): > >types.MethodType( function, instance ) > >functools.partial( function, instance ) > >new_method.__get__( instance ) > > I wonder which of these three possibilities expresses > the idea of creating a new method from a function and > an instance most clearly. The first one. And only the first one. The second one requires too much inside knowledge of Python to make the leap from currying to instance method. The third one doesn't even mention the function. Also, in Python, if I'm applying dunder methods directly (it's okay to write them), then I'm doing something wrong. -- https://mail.python.org/mailman/listinfo/python-list
Re: Regarding python 3.10 installation
In order to save time for the experts here: On 19/09/2022 00.51, Shadid Alam wrote: Hello I’ve been trying to install updated python version i.e. python 10.7. There is no python 10.7. Are you possibly trying to install python 3.10.7? On what OS are you trying to install it? How are you trying to install it? Do you get any error messages when you try to install it? Its showing installed but whenever I open python it comes up with the older How are you "opening" it? version i.e. 10.9 . Please fix this issue is possible In order to do that, we'll need your root password and IP address. -- Michael F. Stemper Psalm 82:3-4 -- https://mail.python.org/mailman/listinfo/python-list
Re: Python is not working on my desktop
Regret to advise that many members will not click on links, and particularly not when the link is the only message-content. (flagged as likely spam-email!) Please describe the problem, including an explanation of from where the Python interpreter was downloaded, which OpSys is in-use, what commands were issued at the desktop, and copy-paste any results. Does the Python documentation (including the specific page covering installing Python on MS-Windows) help with the above? List-members are volunteers and not $paid. Please help us to help you! Also, please be advised that there is a Python-Tutor Discussion List which handles beginner and learner conversations. On 19/09/2022 23.43, python 3.0 is not working wrote: > > > > >Sent from [1]Mail for Windows -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: How to replace an instance method?
On 9/19/22, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2022-09-18 at 09:11:28 +, > Stefan Ram wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated): >> >types.MethodType( function, instance ) >> >functools.partial( function, instance ) >> >new_method.__get__( instance ) >> >> I wonder which of these three possibilities expresses >> the idea of creating a new method from a function and >> an instance most clearly. > > The first one. And only the first one. > > The second one requires too much inside knowledge of Python to make the > leap from currying to instance method. > > The third one doesn't even mention the function. The OP's example named the function "new_method". In general the third case would be func.__get__(instance). It's how the interpreter binds a new method when a function from the class hierarchy is accessed as an instance attribute. When a function from the class hierarchy is accessed as an attribute of the class, it's equivalent to calling func.__get__(None, cls), which just returns a reference to the function. To use the descriptor protocol to bind a function as a method of the class requires wrapping it with the classmethod descriptor type. For example, classmethod(func).__get__(None, cls) returns a method object with __self__ that references the cls type. Of course, calling types.MethodType(func, cls) is easier to understand and the preferred way. -- https://mail.python.org/mailman/listinfo/python-list