Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sre_constants MODIFIED CLASS - ERROR

26 views
Skip to first unread message

נתי שטרן

unread,
Jun 24, 2022, 4:42:08 AM6/24/22
to
class _NamedIntConstant(int):
def __new__(cls, value, name):
self = super(_NamedIntConstant, cls).__new__(cls, value)
self.name = name
return self

def __repr__(self):
return self.name

__reduce__ = None
MAXREPEAT = _NamedIntConstant(32,name=str(32))

what's the problem with the code????

Chris Angelico

unread,
Jun 24, 2022, 4:48:57 AM6/24/22
to
You ripped a bunch of code from the standard library without
understanding what it does, and now it doesn't work. The problem is
more with your methodology than your code.

Why are you doing this? Why not simply use what's there?

If you REALLY need to make source-level changes, make *changes*, don't
try to lift small parts out. Also, you will need to spend some hours
getting to know the code that you're mutating.

Is there an alternative newsgroup for
lazy-python-users-who-d...@groups.google.com ?

ChrisA

נתי שטרן

unread,
Jun 24, 2022, 4:54:38 AM6/24/22
to
I did the changes on local copy of this code

‫בתאריך יום ו׳, 24 ביוני 2022 ב-11:50 מאת ‪Chris Angelico‬‏ <‪
ros...@gmail.com‬‏>:‬
> --
> https://mail.python.org/mailman/listinfo/python-list
>


--
<https://netanel.ml>

Roel Schroeven

unread,
Jun 24, 2022, 5:01:41 AM6/24/22
to
Op 24/06/2022 om 10:43 schreef נתי שטרן:
> what's the problem with the code????
Have you seen the replies from Mats Wichmann and Chris Angelico, who
helpfully pointed out some problems with your code and possible
improvements? Please take those into account instead of asking the same
thing over and over.

--
"Il semble que la perfection soit atteinte non quand il n'y a plus rien à
ajouter, mais quand il n'y a plus rien à retrancher."
"Perfectie is niet bereikt als er niets meer toe te voegen is, maar als er
niets meer weg te nemen is."
-- Antoine de Saint-Exupéry

נתי שטרן

unread,
Jun 24, 2022, 5:09:07 AM6/24/22
to
OK. I lifted the full library to a HUGE python file that was saved on LAN
in MY WORK
Do I need to lift many other libraries to the file?
I glad to any answer

Roel Schroeven

unread,
Jun 24, 2022, 7:34:28 AM6/24/22
to
Op 24/06/2022 om 11:10 schreef נתי שטרן:
Answer this: what is it that your _actually_ trying to do? What is the
ultimate goal of all that copying and changing? Cause there is almost
always a better and easier way.

--
"You can fool some of the people all the time, and all of the people some
of the time, but you cannot fool all of the people all of the time."
-- Abraham Lincoln
"You can fool too many of the people too much of the time."
-- James Thurber

נתי שטרן

unread,
Jun 24, 2022, 8:15:28 AM6/24/22
to
My TARGET is to bind many code libraries to one Huge code file that works
optimally and do optimizations if needed.
In this file have code of huge part of falconpy, ALL code of re, argparse,
are and many other code libraries

This code file is contained 10k lines of python code



בתאריך יום ו׳, 24 ביוני 2022, 14:37, מאת Roel Schroeven ‏<
ro...@roelschroeven.net>:
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Chris Angelico

unread,
Jun 24, 2022, 8:26:54 AM6/24/22
to
‪On Fri, 24 Jun 2022 at 22:16, ‫נתי שטרן‬‎ <nsh...@gmail.com> wrote:‬
>
> My TARGET is to bind many code libraries to one Huge code file that works
> optimally and do optimizations if needed.
> In this file have code of huge part of falconpy, ALL code of re, argparse,
> are and many other code libraries
>
> This code file is contained 10k lines of python code
>

Did you check the license terms of all of those libraries? Are you
even legally allowed to do that?

ChrisA

נתי שטרן

unread,
Jun 24, 2022, 8:42:34 AM6/24/22
to
Where found the license of those libraries?
P. S. The copied and modified code used only for internal use


בתאריך יום ו׳, 24 ביוני 2022, 15:28, מאת Chris Angelico ‏<ros...@gmail.com>:
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Roel Schroeven

unread,
Jun 24, 2022, 10:18:59 AM6/24/22
to
Op 24/06/2022 om 14:14 schreef נתי שטרן:
> My TARGET  is to bind many code libraries to one Huge code file that
> works optimally and do optimizations if needed.
> In this file have code of huge part of falconpy, ALL code of re,
> argparse, are and many other code libraries
Don't do that. Sorry, it's just as simple as that. Don't do that. All
those modules are not designed to put together like that, all their
namespaces merged together. Don't do it.
Even if you could eventually get it to work, it would not be any more
optimal.

If you need more performance, look into things like Pypy or Cython.

--
"Experience is that marvelous thing that enables you to recognize a
mistake when you make it again."
-- Franklin P. Jones

נתי שטרן

unread,
Jun 24, 2022, 11:28:09 AM6/24/22
to
I copied most of the libraries from cython
בתאריך יום ו׳, 24 ביוני 2022, 17:18, מאת Roel Schroeven ‏<
ro...@roelschroeven.net>:

Dennis Lee Bieber

unread,
Jun 24, 2022, 2:19:26 PM6/24/22
to
On Fri, 24 Jun 2022 15:14:50 +0300, ??? ???? <nsh...@gmail.com> declaimed
the following:

>My TARGET is to bind many code libraries to one Huge code file that works
>optimally and do optimizations if needed.
>In this file have code of huge part of falconpy, ALL code of re, argparse,
>are and many other code libraries
>
>This code file is contained 10k lines of python code
>

Which means any program that just uses regular expressions has to
import, parse, and byte-code compile all 10K lines.

There is a reason Python doesn't make super all-in-one libraries.


--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Dennis Lee Bieber

unread,
Jun 24, 2022, 2:28:36 PM6/24/22
to
On Fri, 24 Jun 2022 18:27:33 +0300, ??? ???? <nsh...@gmail.com> declaimed
the following:

>I copied most of the libraries from cython

I doubt that... cython is a specialized Python COMPILER system.
"CPython" is the common interpreted Python language (implemented in C), and
is the most likely source of the packages you are mongrelizing..

https://cython.org/
"""
Cython is an optimising static compiler for both the Python programming
language and the extended Cython programming language (based on Pyrex). It
makes writing C extensions for Python as easy as Python itself.
"""
"""
The Cython language is a superset of the Python language that additionally
supports calling C functions and declaring C types on variables and class
attributes. This allows the compiler to generate very efficient C code from
Cython code. The C code is generated once and then compiles with all major
C/C++ compilers in CPython 2.6, 2.7 (2.4+ with Cython 0.20.x) as well as
3.3 and all later versions.

נתי שטרן

unread,
Jun 25, 2022, 2:50:42 PM6/25/22
to
correction:
This is CPYTHON * and not * CYTHON

https://github.com/python/cpython/blob/3.10/Lib/sre_constants.py

‫בתאריך שבת, 25 ביוני 2022 ב-3:27 מאת ‪Dennis Lee Bieber‬‏ <‪
wlf...@ix.netcom.com‬‏>:‬
0 new messages