Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 28 20:38
    swiergot commented #173
  • Sep 28 18:15
    swiergot commented #168
  • Sep 28 15:52
    swiergot opened #173
  • Sep 28 15:29
    EntilZha commented #168
  • Sep 28 12:08
    swiergot commented #168
  • Aug 05 20:47

    dependabot[bot] on pip

    (compare)

  • Aug 05 20:47
    EntilZha closed #172
  • Aug 05 20:47

    EntilZha on master

    Bump urllib3 from 1.26.2 to 1.2… (compare)

  • Aug 05 20:39
    codecov[bot] commented #172
  • Aug 05 20:39
    codecov[bot] commented #172
  • Aug 05 20:36
    dependabot[bot] labeled #172
  • Aug 05 20:36
    dependabot[bot] opened #172
  • Aug 05 20:36

    dependabot[bot] on pip

    Bump urllib3 from 1.26.2 to 1.2… (compare)

  • Jun 04 16:06

    EntilZha on master

    Update DNS (compare)

  • May 27 02:16
    weditor commented #118
  • May 27 02:16
    weditor commented #118
  • Apr 22 19:35
    EntilZha commented #171
  • Apr 22 19:04
    MalongTang edited #171
  • Apr 22 19:03
    MalongTang closed #171
  • Apr 22 18:57
    MalongTang opened #171
Pedro Rodriguez
@EntilZha
and not using C code
Going to open an issue to document this and whatever fix I figur eout
Adrian Wielgosik
@adrian17
Sure. Technically it's not a release blocker.
Pedro Rodriguez
@EntilZha
Ill give a shot at fixing it
see if there is a relatively easy way to do it
Shooting to release in next few days though
then try to publicize/advertise/etc more
the wealth of linq-like libraries make it clear that something like this is desired, but a lot of them seem abandoned
Adrian Wielgosik
@adrian17
Sure.
Hm
Pedro Rodriguez
@EntilZha
how bad is leaving a file open?
Adrian Wielgosik
@adrian17
Well, Python leaves it open unless you explicitly call close().
Pedro Rodriguez
@EntilZha
right
or with a with block
I wonder how the scoping works
if I return from inside a with block
the file iterator
if it closes after the function returns
probably I think
I think the best I can do
well maybe not best
but one thing I could do, is that after the file is iterated over, if nothing else happens to it the file stays open. If it is iterated over again, __iter__ is called, so I can close the old file before making a new one
Pedro Rodriguez
@EntilZha
but to close the file taht is iterated over, requires catching the StopIteration exception, which I cant do if I define a custom next
going to test that real quick
Adrian Wielgosik
@adrian17
On another topic... I'm slightly concerned about code duplication for select/map, where/filter. They're basically aliases, the only thing that's really differing between them is the debug lineage text.
Another thing, about tests, it's possible that if you mocked file IO (instead of using real files), you may be able to check if the file is properly opened/closed and iterated no more than necessary.
Just random suggestions I guess
Pedro Rodriguez
@EntilZha
true
I am thinking about sometime in the future, allowing the LINQ funcitons (select/where/etc) to pass strings
which are parsed
somehow
and applied
although for now, they are just aliases
I could probably find a better way to reduce code duplication though
good idea for tests though
Pedro Rodriguez
@EntilZha
Changing LazyFile to this solves the problem:
class LazyFile(object):
    # pylint: disable=too-few-public-methods,too-many-instance-attributes
    def __init__(self, path, delimiter=None, mode='r', buffering=-1, encoding=None,
                 errors=None, newline=None):
        # pylint: disable=too-many-arguments
        self.path = path
        self.delimiter = delimiter
        self.mode = mode
        self.buffering = buffering
        self.encoding = encoding
        self.errors = errors
        self.newline = newline
        self.file = None

    def __iter__(self):
        if self.file is not None:
            self.file.close()
        self.file = builtins.open(self.path, mode=self.mode, buffering=self.buffering,
                                  encoding=self.encoding, errors=self.errors, newline=self.newline)
        return self.file
however, the file stays open...
Pedro Rodriguez
@EntilZha
This fixes it
class LazyFile(object):
    # pylint: disable=too-few-public-methods,too-many-instance-attributes
    def __init__(self, path, delimiter=None, mode='r', buffering=-1, encoding=None,
                 errors=None, newline=None):
        # pylint: disable=too-many-arguments
        self.path = path
        self.delimiter = delimiter
        self.mode = mode
        self.buffering = buffering
        self.encoding = encoding
        self.errors = errors
        self.newline = newline
        self.file = None

    def __iter__(self):
        with builtins.open(self.path,
                           mode=self.mode,
                           buffering=self.buffering,
                           encoding=self.encoding,
                           errors=self.errors,
                           newline=self.newline) as file_content:
            for line in file_content:
                yield line
Pedro Rodriguez
@EntilZha
Alright, the fix is pushed to master
Pedro Rodriguez
@EntilZha
Anyone have suggestions for the docs? They look good to me but a second oppinion would be nice
Adrian Wielgosik
@adrian17
Nice, a fix that simplifies code is a great fix.
I don't really have to say anything about the docs.
Pedro Rodriguez
@EntilZha
Cool. Will be taking a last lookover, adding some docs to some of the internally used modules/functions/classes, then preparing for release
Pedro Rodriguez
@EntilZha
Well, after a while of wrestling with the release, its done. In releasing 0.4.0 I found an issue where because the wheel distribution depends on the build environment (aka, running on python 2 including enum34 breaking python3 OR running on python3 not including enum34 and breaking python2) I needed to make a hotfix release in 0.4.1
Solution was to completely remove enum34 since I don't use it all that much so its not worth the monolithic hastle (and I dont trust enum-compat either)
Adrian Wielgosik
@adrian17
Hm, google groups? Seems like an overkill, with how little talk happens here and on GH issues. Also making the contents hidden is unusual.
Adrian Wielgosik
@adrian17

Small suggestions:

  • make __str__ show only part of the sequence, as in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...]. Would be even greater if this only evaluated this part, as this would make it usable with infinite generators.*
  • make __repr__ show what it really is; maybe <Sequence: [1, 2, 3, 4...]>or not evaluate at all and show <Sequence wrapping list>, <Sequence wrapping generator>, <Sequence wrapping File>
  • add seq.count as a wrapper for itertools.count? I'm not sure how far down the "replace seq(thing()) with seq.thing()" path you want to go, that may be an overkill.

*(seq(itertools.count()) just killed my computer :P)